Facebook的聊天 - X-FACEBOOK平台认证 [英] Facebook chat - X-FACEBOOK-PLATFORM authentication

查看:112
本文介绍了Facebook的聊天 - X-FACEBOOK平台认证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立在Android上的XMPP客户端,我知道了完美的运行与验证使用摘要-MD-5,但是当我尝试将其转换至X-FACEBOOK平台的它一直失败。

I want to build an XMPP client on android, I've got it running perfect with authentication using Digest-MD-5, however when I try to convert it to X-FACEBOOK-PLATFORM it keeps failing.

推荐答案

因此​​,基本上在X-FACEBOOK平台的身份验证使用的访问令牌中的一部分。这就是所谓的会话密钥。

So basically the X-FACEBOOK-PLATFORM authentication uses only a part of a access token. That is called the session key.

的访问令牌分开由|字符,所以你拆访问令牌,只有采取在中心的角色。请参考下。

The access token is seperated by "|" characters, so you split the access token and only take the characters that are in the center. Refer below.

******|a681464febcefb8*-**|******

******|a681464febcefb8*-**|******

long callId = new GregorianCalendar().getTimeInMillis() / 1000L;

            String sig = "api_key=" + apiKey
                            + "call_id=" + callId
                            + "method=" + method
                            + "nonce=" + nonce
                            + "session_key=" + sessionKey
                            + "v=" + version
                            + appSecret;

            try {
                sig = MD5(sig);
            }
            catch (NoSuchAlgorithmException e) {
                throw new IllegalStateException(e);
            }

            String composedResponse = "api_key=" + URLEncoder.encode(apiKey, "utf-8")
                                        + "&call_id=" + callId
                                        + "&method=" + URLEncoder.encode(method, "utf-8")
                                        + "&nonce=" + URLEncoder.encode(nonce, "utf-8")
                                        + "&session_key=" + URLEncoder.encode(sessionKey, "utf-8")
                                        + "&v=" + URLEncoder.encode(version, "utf-8")
                                        + "&sig=" + URLEncoder.encode(sig, "utf-8");

这篇关于Facebook的聊天 - X-FACEBOOK平台认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆