【问题标题】:JAXL XMPP script works, but never stops loadingJAXL XMPP 脚本有效,但从不停止加载
【发布时间】:2013-02-06 04:42:30
【问题描述】:

我在我的网站中实现 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";

【问题讨论】:

    标签: php xmpp facebook-chat


    【解决方案1】:

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

    在添加“$client->send_end_stream();”之前,我得到了相同的结果(页面不断加载)在 on_auth_success 函数的末尾。

    $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();
    });
    

    似乎脚本在没有事件发生时暂停。 后来页面超时。

    【讨论】:

      猜你喜欢
      • 2014-09-19
      • 2018-09-18
      • 2012-11-05
      • 1970-01-01
      • 2015-05-17
      • 2023-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多