Sterpu Mihai
Sterpu Mihai

Reputation: 618

facebook graph api create wall post with uploaded picture

I'm following these steps to create a wall post with a picture using the FB Graph API:

  1. Upload the picture into a specified folder (working OK) -> this returns an id and a post_id
  2. Send a POST to https://graph.facebook.com/me/feed with the following parameters:

access_token - my current access_token

message - a simple message like "hello"

object_id -the post_id obtained in step 1, after photo upload

The post message appears on the wall, but there is no photo:

http://img545.imageshack.us/img545/1369/screenshot6ev.png

What am I doing wrong?

I mention that i don't want to attach a link to the photo. I want the image to appear without any hiperlink, like the ones that are manually uploaded when creating a new post.

Upvotes: 3

Views: 14133

Answers (4)

user2783280
user2783280

Reputation: 5

You should use /me/photos without no_story parameter. You can add your message to message parameter and it will appear on the user's story board.

Upvotes: 0

Alena
Alena

Reputation: 1120

Use you photo_id after photo upload to get photo info. Photo info includes a set of links to its thumbnails. User one of the thumbnail link to post on the wall by "/me/feed" graph API. See the link to get more details: https://stackoverflow.com/a/23199781/989896

Upvotes: 0

Tyler Liu
Tyler Liu

Reputation: 20396

It should be object_attachment instead of object_id.

Check the document here: https://developers.facebook.com/docs/graph-api/reference/user/feed/

Upvotes: 3

Steve Teale
Steve Teale

Reputation: 219

I've been struggling with the same thing - it seems like a gross omission from the APIs to leave out something which is what most people do.

The only way around it that I have found is to first create a unique serial-numbered album, and then post the photo to that album:

FB.api('ALBUM_ID/photos', 'post', params, function(response) { ... });

Where params contains the post message and the url of the photo/picture. But it's such a kludge, creating an album for a single picture! However, that way you don't get subsequently posted pictures grouped together.

There is a more complete code snippet at How to do simple Facebook status post with text and picture.

Upvotes: 1

Related Questions