3

I want to post a picture to the wall, just like what I can do from the facebook web page.

I've tried these two ways, but both not what I want.

  1. [ http://facebook.stackoverflow.com/questions/5168145/android-post-picture-to-facebook-wall ] This one just upload pictures to the photo gallery, there will be a message on the wall, but it's not actually a post. Multiple pictures will be put in the same message.
  2. [ Android how to post picture to friend's wall with facebook android sdk ] This one post to the wall, with link to the picture. But it looks like sharing a link, the picture is so small.

Is it possible to make a wall post with a picture (a file from the phone, not URL)?

Which looks like I posted from the "Upload Photo" on facebook website.

https://i.stack.imgur.com/o16Hn.png (sorry I can't post image)

Thanks!

Community
  • 1
  • 1
rexx
  • 88
  • 1
  • 9
  • Have a look http://stackoverflow.com/questions/8030548/android-post-image-to-facebook/13032345#13032345 hope this will help you – Ashish Dwivedi Oct 23 '12 at 14:11

1 Answers1

2

The accepted answer in the 1st thread is correct, with just one change, you see when you upload a picture in facebook, like in the screen capture you added, you post it to a specific album titled "Wall Photos".

In that answer they used me/photos, and that will create an album for the app (if one isn't already existing) and post the image there.

I think that this should work:

Bundle params = new Bundle();
params.putByteArray("source", imageBytes);
params.putString("message", "A wall picture");
facebook.request("me/feed", params, "POST");

(you can obviously use the async runner)

If that does not work, then you'll have to get the "wall photos" album id of the logged in user first and then do something like:

Bundle params = new Bundle();
params.putByteArray("source", imageBytes);
params.putString("message", "A wall picture");
facebook.request("ALBUM_ID/photos", params, "POST");
Nitzan Tomer
  • 155,636
  • 47
  • 315
  • 299
  • Thanks! The second one works!! So the point is the special album "wall photos". – rexx Apr 15 '12 at 14:48
  • I haven't tried the first one, but I've tried to post to "me/feed" with byte array in "picture", does not work. It seems feed accepts only links to a picture. – rexx Apr 15 '12 at 14:54
  • Have you tried using the "source" parameter instead of "picture", as in the code I posted? – Nitzan Tomer Apr 15 '12 at 15:08
  • I've tried using "source" to post to "me/feed", only the message appears. And there's no "source" field in the document, so I think it does not work. https://developers.facebook.com/docs/reference/api/user/#posts – rexx Apr 16 '12 at 13:46
  • Yeah, well, the "right" way to do it is the 2nd option I wrote, I just took a shot with the first.. – Nitzan Tomer Apr 16 '12 at 13:51
  • how to get Album_ID?or can i just use "ALBUM_ID/photos"? – Amel Jose Apr 10 '13 at 09:53