我正在尝试将facebook聊天集成到我们的移动Flash/AIR应用程序中,并使用XIFF来处理XMPP内容。当然,我不得不为新的Facebook API修改一些文件,它使用access_token而不是sig和secret。
对于那些熟悉xiff/smack API的人来说,我是如何建立连接的:
XFacebookPlatform.setFacebookSessionValues(AppData.FACEBOOK_APP_ID, AppData.getInstance().getFBSession().accessToken);
XMPPConnection.registerSASLMechanism("X-FACEBOOK-PLATFORM", XFacebookPlatform);
var con :XMPPConnection = new XMPPConnection();
con.server = "chat.facebook.com";
con.useAnonymousLogin = true;
con.connect(XMPPConnection.STREAM_TYPE_STANDARD);。
基本上,我达到了用IMO应该是正确的格式回答挑战的地步:
var responseMap:Dictionary = new Dictionary();
responseMap.api_key = fb_api_key;
responseMap.call_id = 0;
responseMap.method = incomingChallengeMap.method;
responseMap.nonce = incomingChallengeMap.nonce;
responseMap.access_token = user_access_token;
responseMap.v = "1.0";
var challengeResponse:String = "api_key=" + responseMap.api_key;
challengeResponse += "&call_id=" + responseMap.call_id;
challengeResponse += "&method=" + responseMap.method;
challengeResponse += "&nonce=" + responseMap.nonce;
challengeResponse += "&access_token=" + responseMap.access_token;
challengeResponse += "&v=" + responseMap.v;
challengeResponse = Base64.encode( challengeResponse );。
响应已发送,但作为响应,我收到以下内容:
<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
<not-authorized xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>这听起来像是我没有授予"xmpp_login",但我做到了。我通过Graph API explorer进行了检查,对于相同的access_token,它显示:
{
"data": [
{
"installed": 1,
"xmpp_login": 1,
"user_online_presence": 1,
"friends_online_presence": 1
}
]
}我想,这应该足够了。
但是我仍然得到了“未授权”的失败。你知道这里出了什么问题吗?
发布于 2012-06-08 01:30:58
有趣的是,问题出在这一行:
var con :XMPPConnection = new XMPPConnection();它必须替换为下面这一行:
var con :XMPPTLSConnection = new XMPPTLSConnection();就这样。facebook聊天仅通过TLS连接进行身份验证。
。
虽然这确实有意义,但
<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
<not-authorized xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>在这里,非常具有误导性,因为它暗示权利的某些东西将是错误的。
https://stackoverflow.com/questions/10933821
复制相似问题