drll85318 2013-02-06 04:42 采纳率: 100%
浏览 17

JAXL XMPP脚本可以工作,但永远不会停止加载

I am implementing the Facebook Chat into my site so I used JAXL in order to implement the XMPP. It seems that the script posts the message that I wanted, but whenever I run it, the page just keeps loading and loading and never stops. In order to get back onto that site, I have to clear the cookies for it in my browser. Not sure what the problem could be, I am not seeing any errors in my log. Take a look at the code: Thanks!

$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";
  • 写回答

1条回答 默认 最新

  • dongluoheng3324 2013-03-21 08:44
    关注

    I've tested your code with a local jabber server.

    I got the same result (page keeps loading) until I added a "$client->send_end_stream();" at the end of the on_auth_success function.

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

    It seems that the scripts supsends while no events occur. Later the page times out.

    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么