JAXL XMPP脚本可以工作,但从不停止加载


JAXL XMPP script works, but never stops loading

我正在我的网站中实现Facebook聊天,所以我使用JAXL来实现XMPP。脚本似乎发布了我想要的消息,但每当我运行它时,页面就会不断加载,从未停止。为了回到那个网站,我必须清除浏览器中的cookie。不确定可能是什么问题,我在日志中没有看到任何错误。看看代码:谢谢!

$client = new JAXL(array(
        'jid' => $user['facebookID']."@chat.facebook.com",
        'fb_app_key' => "XXXX",
        'fb_access_token' => $user['facebook_access_token'],
        'force_tls' => true,
        'auth_type' => 'X-FACEBOOK-PLATFORM',
        'log_level' => JAXL_INFO,
        'priv_dir' => "includes/lib/jaxl/tmp"
    ));
    $client->add_cb('on_auth_success', function() {
        global $client;
        _info("got on_auth_success cb, jid ".$client->full_jid->to_string());
        $client->set_status("available!", "dnd", 10);
        $msg = new XMPPMsg(array('to'=>'-XXXX@chat.facebook.com'), 'test message');
        $client->send($msg);
    });
    $client->add_cb('on_auth_failure', function($reason) {
        global $client;
        $client->send_end_stream();
        _info("got on_auth_failure cb with reason $reason");
    });
    $client->add_cb('on_chat_message', function($stanza) {
        global $client;
        // echo back incoming message stanza
        $stanza->to = $stanza->from;
        $stanza->from = $client->full_jid->to_string();
        $client->send($stanza);
    });
    $client->add_cb('on_disconnect', function() {
        _info("got on_disconnect cb");
    });
    //
    // finally start configured xmpp stream
    //
    $client->start();
    echo "done";

我已经用本地jabber服务器测试了您的代码。

我得到了相同的结果(页面一直在加载),直到我在on_auth_success函数的末尾添加了一个"$client->send_end_stream();"。

$client->add_cb('on_auth_success', function() {
    global $client;
    _info("got on_auth_success cb, jid ".$client->full_jid->to_string());
    $client->set_status("available!", "dnd", 10);
    $msg = new XMPPMsg(array('to'=>'-XXXX@chat.facebook.com'), 'test message');
    $client->send($msg);
    // Close the connection
    $client->send_end_stream();
});

脚本似乎在没有事件发生的情况下暂停。稍后页面超时。