Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am developing an application in which user can share messages with his/her Facebook friends. I am using Facebook API for android. I can able to authenticate user, as well as I can get my friend list as a Facebook user and also post message on wall, but I am looking for sending private message to my friends and I didn't get any solution for that, so can any body help me, how can I achieve ...

Thanks in advance

Best Regards

share|improve this question
1  
Possible duplicate : stackoverflow.com/questions/2574431/… –  Kazekage Gaara May 26 '12 at 7:59

2 Answers 2

up vote 6 down vote accepted

It is not possible to send private messages on the behalf of the user using the graph api.

You should however be able to use the Send Dialog, though I haven't tried it on android, but it should be something like:

Bundle params = new Bundle();
params.putString("to", "USER_ID");
params.putString("name", "TITLE HERE");
params.putString("link", "A URL"); // this link param is required

facebook.dialog(context, "send", params, new DialogListener() {
    @Override
    public void onComplete(Bundle values) {
       ....
    }

    @Override
    public void onFacebookError(FacebookError error) {}

    @Override
    public void onError(DialogError e) {}

    @Override
    public void onCancel() {}
});

Another approach you can use is the Chat API with which you can send messages on the behalf of the user, it requires the xmpp_login permission and you to implement an xmpp client.


Edit

Since this dialog is not supported yet in android, you have 3 options:

  1. Wait for facebook to implement the dialog for android.
  2. Try to open the dialog in a browser (the url for that is in the docs) in the mobile device.
  3. Ask for the xmpp_login and add a xmpp client (i.e.: asmack) and with that you can implement your own "Send Message" dialog.
share|improve this answer
    
Thanks for your answer. already i used above code but in Send Dialog it says "This Dialog is currently not supported on mobile devices". –  Ramakrishna May 26 '12 at 11:21
    
Eh, I was afraid of that (since it's not in the docs), but was worth the try. I edited my answer with more info. –  Nitzan Tomer May 26 '12 at 11:31
    
Okay thanks. I will try 2nd or 3rd option. –  Ramakrishna May 26 '12 at 11:37

Latest Android SDK features now the (private) Message Dialog
https://developers.facebook.com/docs/android/message-dialog/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.