3

I am trying to post on the wall or send a private message to a friend.. I am using the latest SDK 3.5. I read that we should use the feed dialog to perform it.

my Code

private void publishFeedDialog() {
    try{
        Bundle params = new Bundle();
        params.putString("name", "Facebook SDK for Android");//title 
        params.putString("caption", "Build great social apps and get more installs.");//caption 
        params.putString("description", "The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps.");

        WebDialog feedDialog = (
                new WebDialog.FeedDialogBuilder(InviteParticipantsActivity.this,
                    Session.getActiveSession(),
                    params))
                .setOnCompleteListener(null)
                .build();
            feedDialog.show();
}
catch(Exception e){
    e.printStackTrace();
}
}

This code will post it on my wall but I am looking to post it on a friends wall or send a message.

I have all the details such as the name and id of the target user.

Sanket Kachhela
  • 10,861
  • 8
  • 50
  • 75
Srikanth Pai
  • 926
  • 3
  • 17
  • 30

2 Answers2

3
params.putString("to", "TARGET Facebook USER ID");

To post on your friends wall Add the parameter "to"

Srikanth Pai
  • 926
  • 3
  • 17
  • 30
  • please refer to this link I am getting an error http://stackoverflow.com/questions/21678055/an-error-occured-while-posting-to-friends-wall-using-facebook-android-sdk-3-6-n?noredirect=1#comment32770939_21678055 – user1891910 Feb 10 '14 at 14:07
  • Can we put multiple ids to share with multiple friends? If not how can we share text with multiple friends? – Hardik Joshi Apr 26 '14 at 11:55
-1

Use below code. Use setTo() method where you have to pass the ID of the friend as parameter .

 WebDialog feedDialog =( new WebDialog.FeedDialogBuilder(getApplicationContext(), Session.getActiveSession(), null).setTo(ID)).setOnCompleteListener(null).build()
                feedDialog.show();
Madhu
  • 298
  • 1
  • 12
  • you can post on a friends wall.. I am sure about it – Srikanth Pai Sep 24 '13 at 11:49
  • @contactmeandroid you can see this link http://developers.facebook.com/blog/post/2013/06/26/october-2013-platform-changes/ – Madhu Sep 24 '13 at 12:12
  • read it carefully it says " Please use the Feed Dialog for posting." – Srikanth Pai Sep 24 '13 at 12:18
  • i got that.. but it takes only one id at a time.. any idea for sending group messages? I tried comma separated id's butdidn't work – Srikanth Pai Sep 24 '13 at 13:42
  • @contactmeandroid in setTo method you can pass comma separated ids. String ids = idList.get(0); for (int i = 1; i < idList.size(); i++) { ids = ids + "," + idList.get(i); } where idList is list of ids. It worked for me. – Madhu Sep 25 '13 at 04:34
  • Instead of posting to wall can we send a private message using feed dialog? – Srikanth Pai Sep 25 '13 at 11:36
  • 1
    @contactmeandroid this link may help you http://stackoverflow.com/questions/10764381/send-private-message-to-my-friends-using-my-android-application – Madhu Sep 25 '13 at 12:02
  • @Madhu I can't post to multiple ids, I tried with the comma: .setTo("677718938956578,420195354761298") are you sure? This is all: WebDialog feedDialog = ( new WebDialog.FeedDialogBuilder(QuestionsActivity.this, Session.getActiveSession(), params)) .setTo("677718938956578,420195354761298") .setOnCompleteListener(new OnCompleteListener() { LONG STUFF }) .build(); – Accollativo Oct 31 '13 at 18:21
  • @Accollativo Do you post to multiple ids.If yes ,will you please give the code. – Jithin Sunny Mar 03 '14 at 10:55
  • @Sunny no, It's not possible. If you find some trick please tell me :) – Accollativo Mar 03 '14 at 13:12