使用SASL X-FACEBOOK_PLATFORM的FB聊天不起作用

时间:2012-05-01 04:17:41

标签: facebook xmpp facebook-apps sasl x-facebook-platform

我正在为FB开发一个简单的聊天客户端。我已经进展到一个状态,现在我拥有登录到我的聊天用户的access_token,其中包含“xmpp_login”和“offline_access”范围。能够成功连接到chat.facebook.com并使用api_key和access_token登录。 SASL身份验证没有问题。

现在,当我尝试使用chat.sendMessage(String)或chat.sendMessage(Message)发送消息时,smack调试器显示消息已发送。但在我的Facebook网站上,我没有看到发送给该人的消息。

hellokVfox0

这是Smack调试器已发送列的输出。来自地址有什么问题吗?或者使用这种消息结构?我坚持这一点,因为我不知道如何调试这个问题。

欢迎任何建议,建议或解决方案。

这是我正在使用的代码段,

        ConnectionConfiguration config = new                 ConnectionConfiguration("chat.facebook.com",5222);//ProxyInfo.forHttpProxy(soc.getHostName(),8080, null, null));
    config.setSASLAuthenticationEnabled(true);
    XMPPConnection connection = new XMPPConnection(config);
    XMPPConnection.DEBUG_ENABLED = true;
    SASLAuthentication.registerSASLMechanism("X-FACEBOOK-PLATFORM", SASLXFBAuthentication.class);
    SASLAuthentication.supportSASLMechanism("X-FACEBOOK-PLATFORM", 0);
    connection.connect();
    String apiKey ="282973731790200";
    String accessToken ="My access token with xmpp_login and offline_access scope";
        connection.login(apiKey, accessToken);
    Chat newchat = connection.getChatManager().createChat("praveen.ganapathi@chat.facebook.com", new MessageListener() {


        public void processMessage(Chat chat, Message message) {
            // Print out any messages we get back to standard out.
            System.out.println("Received message: " + message);
        }
    });
    Message msg = new Message();
    msg.addBody("English", text);
    msg.addSubject("English", "Test");
    msg.setType(Type.chat);
   // connection.sendPacket(msg);
    newchat.sendMessage(msg);   

谢谢和问候, KARTHIK

1 个答案:

答案 0 :(得分:2)

我已经解决了这个问题。

消息所针对的地址也应该是JID格式。要获得这个,我们需要使用Roaster Class of smack并获取facebook中的所有连接或朋友。这样做有助于我向预期的JID发送消息。

谢谢, KARTHIK

相关问题