Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
499 views
in Technique[技术] by (71.8m points)

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...