コード例 #1
0
ファイル: test.php プロジェクト: NemOry/NemSMSWebPanel
function _main()
{
    print "Test platform connect for XMPP<br>";
    $app_id = '508427445917366';
    $app_secret = '57286ce9f8d3441c9b54def91d7862a7';
    $my_url = "http://localhost/";
    $uid = '100000187808439';
    $access_token = get_access_token($app_id, $app_secret, $my_url);
    print "access_token: " . $access_token . "<br>";
    $options = array('uid' => $uid, 'app_id' => $app_id, 'server' => 'chat.facebook.com');
    // prints options used
    print "server: " . $options['server'] . "<br>";
    print "uid: " . $options['uid'] . "<br>";
    print "app id: " . $options['app_id'] . "<br>";
    if (xmpp_connect($options, $access_token)) {
        print "Done<br>";
    } else {
        print "An error ocurred<br>";
    }
}
コード例 #2
0
function _post()
{
    global $app_id, $app_secret, $uid, $recv_id, $access_token;
    // connect to XMPP Authentication
    $server_options = array('app_id' => $app_id, 'server' => 'chat.facebook.com');
    $fp = xmpp_connect($server_options, $access_token);
    // send message
    if ($fp) {
        $msg_options = array('uid' => $uid, 'recv_id' => $recv_id, 'msg' => 'Hi, I am robot. ' . date("Y-m-d H:i:s") . '
             Source Code: https://github.com/hankwang/facebook-chat-bot/');
        xmpp_send_msg($fp, $msg_options);
    } else {
        echo "An error ocurred<br>";
    }
    fclose($fp);
}