3
votes

Does Facebook allow that user A using mobile app posts something (text, image or URL) on user B's wall?

I have been searching for this for a couple of days, but I cannot find anything about it in Facebook API docs.

To make it clear, I do not need to post something on my own wall, but on my friend's wall using Facebook API.

Am I right saying that this is not possible/allowed at this moment?

1
@GeorgyGobozov Hm, this seems like link to posting things on YOUR OWN wall. I need to post something on my friends wall directly from a mobile app. Is this more clear now? Thankssandalone

1 Answers

1
votes

Use this piece of code to post on another user's wall.

Bundle postStatusMessage = new Bundle();

// ADD THE STATUS MESSAGE TO THE BUNDLE
postStatusMessage.putString("message", finalStatusMessage);

Utility.mAsyncRunner.request(userID + "/feed", postStatusMessage, "POST", new StatusUpdateListener(), null);

You can also upload a photo with the above code, like this:

byte[] data = null;

ByteArrayOutputStream baos = new ByteArrayOutputStream();
Bitmap bmpImageCamera.compress(CompressFormat.JPEG, 100, baos);
data = baos.toByteArray();

Bundle postImgGallery = new Bundle();

// ADD THE PHOTO DATA TO THE BUNDLE
postImgGallery.putByteArray("photo", data);

And then use this to check the result.

private class StatusUpdateListener extends BaseRequestListener  {

    @Override
    public void onComplete(String response, Object state) {

    }

    @Override
    public void onFacebookError(FacebookError e, Object state) {

    }

}

If successfully posted, String response in the onComplete() will give you an ID for the post.

NOTE 1: The above code uses the older Facebook SDK (Pre v 3.x) so you will have to adapt the code to work with the new SDK if you are using it. It will need a few minor changes.

NOTE 2: Facebook has planned to stop the ability to let applications post to other users walls. Source: https://developers.facebook.com/blog/post/2012/10/10/platform-updates--operation-developer-love/. Going forward, you will need to use the feed dialog option.