3
我希望发送消息到基于XMPP的聊天服务器使用PHP。 我正在使用JAXL,它似乎是纯PHP服务器聊天的最佳(有限)选项。基于JAXL的聊天客户端。需要帮助连接到Gtalk或其他服务器来测试
不过,我还没有建立任何连接,更不用说发送消息。 我有一个很难制定出如果问题是我的代码,我的服务器(这是共享服务器,但交友,和非常有益的主机),或我的设置。
我使用的尝试连接到GTalk的是代码;
$client = new JAXL(array(
'jid' => '[email protected]',
'pass' => 'password',
'host'=> 'talk.google.com',
'port'=> 5222,
'domain'=> 'gmail.com', //unsure if this is the right setting.
'force_tls' => true,
'auth_type' => @$argv[3] ? $argv[3] : 'PLAIN',
));
//
// required XEP's
//
$client->require_xep(array(
'0199' // XMPP Ping
));
//
// add necessary event callbacks here
//
$client->add_cb('on_auth_success', function() {
global $client;
_info("got on_auth_success cb, jid ".$client->full_jid->to_string());
// fetch roster list
$client->get_roster();
// fetch vcard
$client->get_vcard();
// set status
$client->set_status("available!", "dnd", 10);
});
$client->add_cb('on_connect_error', function() {
echo 'Connect Error';
});
$client->add_cb('on_auth_failure', function() {
echo 'Auth Error';
});
$client->add_cb('on_auth_success', function() {
global $client;
echo 'connected';
$client->send_chat_msg('[email protected]', 'webtest');
$client->shutdown();
});
//
// finally start configured xmpp stream
//
$client->start(array(
'--with-debug-shell' => true,
'--with-unix-sock' => true
));
echo "done\n";
触发PHP(从浏览器),然后导致服务器卡住。 (没有“完成”的消息,只是不断加载,直到从浏览器超时)
服务器日志显示;
strict mode enabled, adding exception handlers. Set 'strict'=>TRUE inside JAXL config to disable this[0m
error handler called with 8, Undefined index: priv_dir,
然后很多;
unable to connect tcp://talk.google.com:5222 with error no: 110, error str: Connection timed out
所以,我会感谢以下任何帮助;
- 任何特定的起步
- 选推荐我的代码
- 与每增加一个连接设置的任何问题,问题来研究这个问题。
- 或者任何成功使用JAXL的人的一般建议。
感谢, 托马斯·罗贝尔
我需要同样的事情从文件XMLStream.php连接,你有没有解决呢? –
否:( 无论在任何地方这个问题的帮助很少。 – darkflame