FB chat using SASL X-FACEBOOK_PLATFORM not working

I am developing a simple chat client for FB. I have progressed to a state where now i have the access_token of the user who had logged in to my chat with “xmpp_login” and “offline_access” scope. Am able to successfully connect to chat.facebook.com and also login using api_key and the access_token. There is no problem in the SASL Authentication.

Now when i try to send a message using, chat.sendMessage(String) or chat.sendMessage(Message), the smack debugger shows the message has been sent. But on my facebook website, I dont see that message sent to that person.

hellokVfox0

This is the output from Smack debugger Sent column. Is there anything wrong with the from address? or with this message structure? Am stuck at this point because i dont know how to debug this issue.

Any advice, suggestions or solutions are most welcome.

This is the code snippet i am using,

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);

Thanks and Regards,

Karthik

Hi guys,

I have fixed this issue.

The to address to whom the message was intended should also be JID format. To obtain this, we need to make use of Roaster Class of smack and get all the connections or friends in facebook. Doing so helped me to send a message to the intended JID.

Thanks,

Karthik