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