Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send private message to my friend(s) using my Android application

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 this?

like image 868
Ramakrishna Avatar asked May 26 '12 07:05

Ramakrishna


People also ask

Can you share a private message?

The fact that distributing a private message may not be a breach of privacy does not mean that you can do so without any legal consequences. The Harmful Digital Communications Act sets out principles to prevent harm from certain online behaviours such as cyber bullying, spreading personal information and so on.

What is Messenger app used for?

Facebook Messenger is a FREE mobile messaging app used for instant messaging, sharing photos, videos, audio recordings and for group chats. The app, which is free to download, can be used to communicate with your friends on Facebook and with your phone contacts.


1 Answers

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.
like image 81
Nitzan Tomer Avatar answered Oct 19 '22 18:10

Nitzan Tomer