我正在为FB开发一个简单的聊天客户端。现在,我已经拥有了使用"xmpp_login“和"offline_access”作用域登录到我的聊天的用户的access_token。我能够成功地连接到chat.facebook.com,也可以使用api_key和access_token登录。SASL身份验证没有问题。
现在,当我尝试使用chat.sendMessage(字符串)或chat.sendMessage(消息)发送消息时,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
发布于 2012-05-03 11:51:01
我已经解决了这个问题。
邮件的收件人地址也应为JID格式。要获得这一点,我们需要利用smack的烘焙类,并在facebook中获得所有的联系或朋友。这样做有助于我向目标JID发送一条消息。
谢谢,Karthik
https://stackoverflow.com/questions/10393497
复制相似问题