连接到谷歌通过使用PHP波什服务器通话

问题描述:

我创建我自己的PHP波什连接器,所以我 可以附加()strophe。这是我的交流,我得到一个错误 身份验证错误(这是一个谷歌特定的错误)。当我与strophe成功连接时,交易似乎与 完全一样,你知道问题是什么吗?连接到谷歌通过使用PHP波什服务器通话

<body rid='5559198240000' xmlns='http://jabber.org/protocol/httpbind' 
to='babson.edu' xml:lang='en' wait='60' hold='1' window='5' 
content='text/xml; charset=utf-8' ver='1.6' xmpp:version='1.0' 
xmlns:xmpp='urn:xmpp:xbosh'/> 

string(500) "<body xmlns='http://jabber.org/protocol/httpbind' 
inactivity='60' secure='true' authid='BECF5BCD50577C01' content='text/xml; 
charset=utf-8' window='5' polling='15' 
sid='4ad843a8e15c79e34976783c96785bd5' requests='2' 
wait='60'><stream:features xmlns:stream='http://etherx.jabber.org/streams' 
xmlns='jabber:client'><mechanisms 
xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mecha 
nism>X-GOOGLE-TOKEN</mechanism><mechanism>X-OAUTH2</mechanism></mechanisms> 
</stream:features></body>" 


<body rid='5559198240001' xmlns='http://jabber.org/protocol/httpbind' 
sid='4ad843a8e15c79e34976783c96785bd5'><auth 
xmlns='urn:ietf:params:xml:ns:xmpp-sasl' 
mechanism='PLAIN'>same_base_64_translated_string_as_in_strophe=</auth></bod 
y> 

string(24) "Error=BadAuthentication 

我检查过了,base_64 SASL编码的字符串与我在strophe日志中的成功连接完全一样。但我的PHP程序发送相同的确切XML获取此BadAuthentication错误。

我用错了卷曲头:

这是使用卷曲说话波什对别人说发现这个职位的正确方法:

$ch = curl_init($bosh_url); 
curl_setopt($ch, CURLOPT_HEADER, 0); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlpost); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
$header = array('Accept-Encoding: gzip, deflate','Content-Type: text/xml; charset=utf-8'); 
curl_setopt($ch, CURLOPT_HTTPHEADER, $header); 
curl_setopt($ch, CURLOPT_VERBOSE, 0); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
$response = curl_exec($ch); 
var_dump($response);