1

我使用 jaxl.V3 连接到 facebook。这是我的代码:

<?php

  require_once '../jaxl.php';
  $client = new JAXL(array(
     'jid' => '(myID)'.'@chat.facebook.com',
     'fb_app_key' => '(MYKeyApp)',
     'fb_access_token' => '(myAccessToken)',
     'domain'=>'chat.facebook.com',
     'host' => 'chat.facebook.com',
     'port'=>5222,
     'boshHost'=>'localhost',
     'priv_dir'  => 'D:/wamp/www/jaxl/.jaxl/tmp',
     'resource' => 'resource', 
     'force_tls' => true,
     'auth_type' => 'X-FACEBOOK-PLATFORM',
     'log_level' => JAXL_DEBUG,
    ));

    $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!", "ol", 10);
        $msg = new XMPPMsg(array('to'=>'-(myFriID)@chat.facebook.com'), $txtMessage);
            $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);
       _info("echo message sent");

           sendMessage($client);
   });

   $client->add_cb('on_disconnect', function() {
       _info("got on_disconnect cb");
   });

   //
   // finally start configured xmpp stream
   //
   $client->start();
   echo "done\n";
   ?>

我已成功通过使用控制台命令行进行 sendMessage 聊天。但我需要的是浏览器。相同的代码配置,如果我通过浏览器运行它,我会在日志文件中收到消息错误,例如:

jaxl_fsm:56 - 2013-04-05 23:00:57 - calling state handler 'setup' for incoming event   'connect'
jaxl_socket_client:91 - 2013-04-05 23:00:57 - trying tcp://chat.facebook.com:5222
jaxl_socket_client:96 - 2013-04-05 23:00:57 - connected to tcp://chat.facebook.com:5222
jaxl_loop:82 - 2013-04-05 23:00:57 - active read fds: 1, write fds: 0
jaxl_fsm:65 - 2013-04-05 23:00:57 - current state 'connected'
jaxl_fsm:56 - 2013-04-05 23:00:57 - calling state handler 'connected' for incoming event 'start_stream'
jaxl_loop:82 - 2013-04-05 23:00:57 - active read fds: 1, write fds: 1
jaxl_fsm:65 - 2013-04-05 23:00:57 - current state 'wait_for_stream_start'
jaxl_socket_client:187 - 2013-04-05 23:00:57 - sent 226/226 of data
jaxl_socket_client:188 - 2013-04-05 23:00:57 - <stream:stream    xmlns:stream="http://etherx.jabber.org/streams" version="1.0" from="100004083275041@chat.facebook.com" to="chat.facebook.com" xmlns="jabber:client"  xml:lang="en" xmlns:xml="http://www.w3.org/XML/1998/namespace">
jaxl_loop:100 - 2013-04-05 23:00:57 - active read fds: 1, write fds: 0
jaxl_socket_client:174 - 2013-04-05 23:00:57 - read 173/173 of data
jaxl_socket_client:175 - 2013-04-05 23:00:57 - <?xml version="1.0"?><stream:stream id="E21DE38D" from="chat.facebook.com" version="1.0" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" xml:lang="en">
jaxl_fsm:56 - 2013-04-05 23:00:57 - calling state handler 'wait_for_stream_start' for incoming event 'start_cb'
jaxl_fsm:65 - 2013-04-05 23:00:57 - current state 'wait_for_stream_features'
jaxl_socket_client:174 - 2013-04-05 23:00:57 - read 227/400 of data
jaxl_socket_client:175 - 2013-04-05 23:00:57 - <stream:features><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>X-FACEBOOK-PLATFORM</mechanism><mechanism>DIGEST-MD5</mechanism></mechanisms></stream:features>
jaxl_fsm:56 - 2013-04-05 23:00:57 - calling state handler 'wait_for_stream_features' for incoming event 'stanza_cb'
jaxl_loop:82 - 2013-04-05 23:00:57 - active read fds: 1, write fds: 1
jaxl_fsm:65 - 2013-04-05 23:00:57 - current state 'wait_for_tls_result'
jaxl_socket_client:187 - 2013-04-05 23:00:57 - sent 61/287 of data
jaxl_socket_client:188 - 2013-04-05 23:00:57 - <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"></starttls>
jaxl_loop:100 - 2013-04-05 23:00:57 - active read fds: 1, write fds: 0
jaxl_socket_client:174 - 2013-04-05 23:00:58 - read 50/450 of data
jaxl_socket_client:175 - 2013-04-05 23:00:58 - <proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>
jaxl_fsm:56 - 2013-04-05 23:00:58 - calling state handler 'wait_for_tls_result' for incoming event 'stanza_cb'
jaxl_exception:48 - 2013-04-05 23:00:58 - got jaxl exception construct with stream_socket_enable_crypto() [<a href='streams.crypto'>streams.crypto</a>]: this stream does not support SSL/crypto, 2, D:\wamp\www\jaxl\core\jaxl_socket_client.php, 127
jaxl_exception:75 - 2013-04-05 23:00:58 - exception handler catched {"xdebug_message":"<tr><th align='left' bgcolor='#f57900' colspan=\"5\"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )<\/span> JAXLException: stream_socket_enable_crypto() [<a href='streams.crypto'>streams.crypto<\/a>]: this stream does not support SSL\/crypto in D:\\wamp\\www\\jaxl\\core\\jaxl_socket_client.php on line <i>127<\/i><\/th><\/tr>\n<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack<\/th><\/tr>\n<tr><th align='center' bgcolor='#eeeeec'>#<\/th><th align='left' bgcolor='#eeeeec'>Time<\/th><th align='left' bgcolor='#eeeeec'>Memory<\/th><th align='left' bgcolor='#eeeeec'>Function<\/th><th align='left' bgcolor='#eeeeec'>Location<\/th><\/tr>\n<tr><td bgcolor='#eeeeec' align='center'>1<\/td><td bgcolor='#eeeeec' align='center'>0.0005<\/td><td bgcolor='#eeeeec' align='right'>396352<\/td><td bgcolor='#eeeeec'>{main}(  )<\/td><td title='D:\\wamp\\www\\jaxl\\examples\\xfacebook_platform_client.php' bgcolor='#eeeeec'>..\\xfacebook_platform_client.php<b>:<\/b>0<\/td><\/tr>\n<tr><td bgcolor='#eeeeec' align='center'>2<\/td><td bgcolor='#eeeeec' align='center'>0.0211<\/td><td bgcolor='#eeeeec' align='right'>1553464<\/td><td bgcolor='#eeeeec'>JAXL->start(  )<\/td><td title='D:\\wamp\\www\\jaxl\\examples\\xfacebook_platform_client.php' bgcolor='#eeeeec'>..\\xfacebook_platform_client.php<b>:<\/b>71<\/td><\/tr>\n<tr><td bgcolor='#eeeeec' align='center'>3<\/td><td bgcolor='#eeeeec' align='center'>0.5094<\/td><td bgcolor='#eeeeec' align='right'>1556144<\/td><td bgcolor='#eeeeec'>JAXLLoop::run(  )<\/td><td title='D:\\wamp\\www\\jaxl\\jaxl.php' bgcolor='#eeeeec'>..\\jaxl.php<b>:<\/b>386<\/td><\/tr>\n<tr><td bgcolor='#eeeeec' align='center'>4<\/td><td bgcolor='#eeeeec' align='center'>0.9847<\/td><td bgcolor='#eeeeec' align='right'>1570632<\/td><td bgcolor='#eeeeec'>JAXLLoop::select(  )<\/td><td title='D:\\wamp\\www\\jaxl\\core\\jaxl_loop.php' bgcolor='#eeeeec'>..\\jaxl_loop.php<b>:<\/b>109<\/td><\/tr>\n<tr><td bgcolor='#eeeeec' align='center'>5<\/td><td bgcolor='#eeeeec' align='center'>0.9883<\/td><td bgcolor='#eeeeec' align='right'>1571360<\/td><td bgcolor='#eeeeec'><a href='http:\/\/www.php.net\/call_user_func' target='_new'>call_user_func<\/a>\n(  )<\/td><td title='D:\\wamp\\www\\jaxl\\core\\jaxl_loop.php' bgcolor='#eeeeec'>..\\jaxl_loop.php<b>:<\/b>133<\/td><\/tr>\n<tr><td bgcolor='#eeeeec' align='center'>6<\/td><td bgcolor='#eeeeec' align='center'>0.9883<\/td><td bgcolor='#eeeeec' align='right'>1571376<\/td><td bgcolor='#eeeeec'>JAXLSocketClient->on_read_ready(  )<\/td><td title='D:\\wamp\\www\\jaxl\\core\\jaxl_loop.php' bgcolor='#eeeeec'>..\\jaxl_loop.php<b>:<\/b>133<\/td><\/tr>\n<tr><td bgcolor='#eeeeec' align='center'>7<\/td><td bgcolor='#eeeeec' align='center'>0.9915<\/td><td bgcolor='#eeeeec' align='right'>1572888<\/td><td bgcolor='#eeeeec'><a href='http:\/\/www.php.net\/call_user_func' target='_new'>call_user_func<\/a>\n(  )<\/td><td title='D:\\wamp\\www\\jaxl\\core\\jaxl_socket_client.php' bgcolor='#eeeeec'>..\\jaxl_socket_client.php<b>:<\/b>178<\/td><\/tr>\n<tr><td bgcolor='#eeeeec' align='center'>8<\/td><td bgcolor='#eeeeec' align='center'>0.9915<\/td><td bgcolor='#eeeeec' align='right'>1572936<\/td><td bgcolor='#eeeeec'>JAXLXmlStream->parse(  )<\/td><td title='D:\\wamp\\www\\jaxl\\core\\jaxl_socket_client.php' bgcolor='#eeeeec'>..\\jaxl_socket_client.php<b>:<\/b>178<\/td><\/tr>\n<tr><td bgcolor='#eeeeec' align='center'>9<\/td><td bgcolor='#eeeeec' align='center'>0.9916<\/td><td bgcolor='#eeeeec' align='right'>1573000<\/td><td bgcolor='#eeeeec'><a href='http:\/\/www.php.net\/xml_parse' target='_new'>xml_parse<\/a>\n(  )<\/td><td title='D:\\wamp\\www\\jaxl\\core\\jaxl_xml_stream.php' bgcolor='#eeeeec'>..\\jaxl_xml_stream.php<b>:<\/b>92<\/td><\/tr>\n<tr><td bgcolor='#eeeeec' align='center'>10<\/td><td bgcolor='#eeeeec' align='center'>0.9916<\/td><td bgcolor='#eeeeec' align='right'>1573960<\/td><td bgcolor='#eeeeec'>JAXLXmlStream->handle_end_tag(  )<\/td><td title='D:\\wamp\\www\\jaxl\\core\\jaxl_xml_stream.php' bgcolor='#eeeeec'>..\\jaxl_xml_stream.php<b>:<\/b>92<\/td><\/tr>\n<tr><td bgcolor='#eeeeec' align='center'>11<\/td><td bgcolor='#eeeeec' align='center'>0.9917<\/td><td bgcolor='#eeeeec' align='right'>1574328<\/td><td bgcolor='#eeeeec'><a href='http:\/\/www.php.net\/call_user_func' target='_new'>call_user_func<\/a>\n(  )<\/td><td title='D:\\wamp\\www\\jaxl\\core\\jaxl_xml_stream.php' bgcolor='#eeeeec'>..\\jaxl_xml_stream.php<b>:<\/b>163<\/td><\/tr>\n<tr><td bgcolor='#eeeeec' align='center'>12<\/td><td bgcolor='#eeeeec' align='center'>0.9917<\/td><td bgcolor='#eeeeec' align='right'>1574720<\/td><td bgcolor='#eeeeec'>JAXLFsm->__call(  )<\/td><td title='D:\\wamp\\www\\jaxl\\core\\jaxl_xml_stream.php' bgcolor='#eeeeec'>..\\jaxl_xml_stream.php<b>:<\/b>0<\/td><\/tr>\n<tr><td bgcolor='#eeeeec' align='center'>13<\/td><td bgcolor='#eeeeec' align='center'>0.9932<\/td><td bgcolor='#eeeeec' align='right'>1576088<\/td><td bgcolor='#eeeeec'><a href='http:\/\/www.php.net\/call_user_func' target='_new'>call_user_func<\/a>\n(  )<\/td><td title='D:\\wamp\\www\\jaxl\\core\\jaxl_fsm.php' bgcolor='#eeeeec'>..\\jaxl_fsm.php<b>:<\/b>58<\/td><\/tr>\n<tr><td bgcolor='#eeeeec' align='center'>14<\/td><td bgcolor='#eeeeec' align='center'>0.9933<\/td><td bgcolor='#eeeeec' align='right'>1576136<\/td><td bgcolor='#eeeeec'>XMPPStream->wait_for_tls_result(  )<\/td><td title='D:\\wamp\\www\\jaxl\\core\\jaxl_fsm.php' bgcolor='#eeeeec'>..\\jaxl_fsm.php<b>:<\/b>58<\/td><\/tr>\n<tr><td bgcolor='#eeeeec' align='center'>15<\/td><td bgcolor='#eeeeec' align='center'>0.9933<\/td><td bgcolor='#eeeeec' align='right'>1576136<\/td><td bgcolor='#eeeeec'>JAXLSocketClient->crypt(  )<\/td><td title='D:\\wamp\\www\\jaxl\\xmpp\\xmpp_stream.php' bgcolor='#eeeeec'>..\\xmpp_stream.php<b>:<\/b>483<\/td><\/tr>\n<tr><td bgcolor='#eeeeec' align='center'>16<\/td><td bgcolor='#eeeeec' align='center'>0.9933<\/td><td bgcolor='#eeeeec' align='right'>1576232<\/td><td bgcolor='#eeeeec'><a href='http:\/\/www.php.net\/stream_socket_enable_crypto' target='_new'>stream_socket_enable_crypto<\/a>\n(  )<\/td><td title='D:\\wamp\\www\\jaxl\\core\\jaxl_socket_client.php' bgcolor='#eeeeec'>..\\jaxl_socket_client.php<b>:<\/b>127<\/td><\/tr>\n<tr><td bgcolor='#eeeeec' align='center'>17<\/td><td bgcolor='#eeeeec' align='center'>0.9933<\/td><td bgcolor='#eeeeec' align='right'>1577176<\/td><td bgcolor='#eeeeec'>JAXLException::error_handler(  )<\/td><td title='D:\\wamp\\www\\jaxl\\core\\jaxl_socket_client.php' bgcolor='#eeeeec'>..\\jaxl_socket_client.php<b>:<\/b>127<\/td><\/tr>\n"}
jaxl:228 - 2013-04-05 23:00:58 - cleaning up pid and unix sock files
jaxl_clock:55 - 2013-04-05 23:00:58 - shutting down clock server...

我已经在 PHP.INI 中启用了 extension=php_openssl.dll。请帮我解决它。请有任何想法。我很快就会寻求你的帮助。谢谢

4

1 回答 1

3

如果有人使用 Jaxl 库并遇到与我相同的问题。您只需通过此安装 OpenSSL

为窗口。一切都是 SSL 不支持的问题都可以解决。如果您像我一样尝试使用 JAXL 库,我建议您使用http_bind进行测试

这可能比我现在尝试的要容易。:D

于 2013-04-10T02:26:21.253 回答