4

My app generates custom listview of friends arrange by their birthday. So I have used SELECT name, uid, pic_square, birthday_date FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) order by birthday_date.

Now when the user click a friend(from the listview) it will prompt the user if s/he want to post to that friends wall. I know how to do it the old way, but I'm getting confuse because of How to send a post to Facebook friend's wall android SDK 3.0 .

In that question:

The Facebook SDK for Android provides a method to let you publish stories from your app to a user's timeline. You can also use this method to post a status update on your user's behalf. This method uses the Graph API, and is an alternative to using the Feed Dialog

http://developers.facebook.com/docs/howtos/androidsdk/3.0/publish-to-feed/

also:

never use Graph-API for posting on friend's wall. because it is disabled after 6, Feb 2013. FB recommend u to use Feed Dialog for posting on friend's or your own wall. this is the link for how to use Feed Dialog : http://developers.facebook.com/docs/howtos/androidsdk/3.0/feed-dialog

I have seen both links, but both only show how to post on your own wall. Can anyone give me a good latest example or at least, point me to the right direction on how to post to your friends wall using the FQL request response via Facebook Android SDK 3.x (As of the moment the version is 3.0.2b)?

2 Answers 2

3

I have found the solution. You only need to add the "to" and "from" parameters. Below is my sample:

For wall posting to a single friend:

    private void publishFeedDialog(String friend_uid) {
        Session session = Session.getActiveSession();
        if (!hasPublishPermission()) {
            // We don't have the permission to post yet.
            session.requestNewPublishPermissions(new Session.NewPermissionsRequest(this, WRITE_PERMISSION));
        }
        if (user != null && friend_uid != null && hasPublishPermission()) {

            final Activity activity = this;
            Bundle params = new Bundle();
            //This is what you need to post to a friend's wall
            params.putString("from", "" + user.getId());
            params.putString("to", friend_uid);
            //up to this
            params.putString("name", "Facebook SDK for Android");
            params.putString("caption", "Build great social apps and get more installs.");
            params.putString("description", "The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps.");
            params.putString("link", "https://developers.facebook.com/android");
            params.putString("picture", "https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png");
            WebDialog feedDialog = (new WebDialog.FeedDialogBuilder(this, Session.getActiveSession(), params))
                    .setOnCompleteListener(new OnCompleteListener() {

                    @Override
                    public void onComplete(Bundle values, FacebookException error) {
                        if (error == null) {
                            // When the story is posted, echo the success
                            // and the post Id.
                            final String postId = values.getString("post_id");
                            if (postId != null) {
                                Toast.makeText(activity,
                                    "Posted story, id: "+postId,
                                    Toast.LENGTH_SHORT).show();
                            } else {
                                // User clicked the Cancel button
                                Toast.makeText(activity, 
                                    "Publish cancelled", 
                                    Toast.LENGTH_SHORT).show();
                            }
                        } else if (error instanceof FacebookOperationCanceledException) {
                            // User clicked the "x" button
                            Toast.makeText(activity, 
                                "Publish cancelled", 
                                Toast.LENGTH_SHORT).show();
                        } else {
                            // Generic, ex: network error
                            Toast.makeText(activity, 
                                "Error posting story", 
                                Toast.LENGTH_SHORT).show();
                        }
                    }

                }).build();
            feedDialog.show();
        }
    }

For wall posting to many friends:

RequestsDialogBuilder instead of FeedDialogBuilder because the second one only allows multiple ids on the parameter "to", while the first one can receive many (not sure about the limit though, but I think is about 50)

credits to: gian1200

7
  • But what do you do if you want to send the same thing to many friends? As far as I know, the "to" parameter only accepts 1 id. The only workaround seems to use a "for" to make a Request for each friend (which seems wrong to me).
    – gian1200
    May 29, 2013 at 17:37
  • I didn't try it yet. Sorry, I'm busy at a project right now, I'll try to find the solution if I have the time. But if you ask me, IF IN CASE there is no function for this, I would suggest wall posting yourself then tagging your friends is a better solution than making a loop for it.
    – Marl
    May 30, 2013 at 11:40
  • 2
    Thanks for your answer. However, I manage to do it by using RequestsDialogBuilder instead of FeedDialogBuilder because the second one only allows multiple ids on the parameter "to", while the first one can receive many (not sure about the limit though, but I think is about 50).
    – gian1200
    May 30, 2013 at 19:02
  • Hello Marl:- you use the SDK 3.0 or new 3.5 and which permission you needed?
    – V.P.
    Oct 7, 2013 at 10:59
  • I've used 3.0, I didn't try the 3.5 sdk yet.
    – Marl
    Oct 9, 2013 at 6:31
0

Possible duplicate... I think you should check the Demo FB provided Facebook - Post to wall from Android application

UPDATED:

Well there is this. http://developers.facebook.com/docs/howtos/androidsdk/3.0/publish-to-feed/

Facebook actually recommends using the Feed. Check it out

1
  • Nope. What I need is to post to a friend's wall, and I can't find example of that(using the FB SDK 3.x).
    – Marl
    Apr 24, 2013 at 2:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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