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.