7

I'm trying post an a message with one image via facebook graph API, and I can't. In new documentation https://developers.facebook.com/docs/graph-api/reference/v2.1/user/feed there is no field for an image.

If I try to use a field "object_attachment", only small thumbnail appears and post is styling like a share link.

If I try to use a field "picture", and use url of photo in the internet there is the same result. I can't post "picture" from local,as here:

$post['picture'] = '@' . realpath($image);

error appears: "picture URL is not properly formatted".

I just used a free web app to make a post with a photo, and result is just right(see attached image)

Please tell me, how can I make a post with the exact result?

enter image description here

Vladimir Mikhaylovskiy
  • 1,955
  • 4
  • 19
  • 28

3 Answers3

7

if you want to post a photo to FB (i.e. in to the Albums) and a text and publish both on the timeline, you need to upload the photo to FB. Not as an attachment with an external URL, but as binary data send to FB.

Have a look at

     https://graph.facebook.com/<user id>/photos

and within that field source

Axel Amthor
  • 10,980
  • 1
  • 25
  • 44
6

With v11.0 I was able to publish a post with an image and a message the following way:

https://graph.facebook.com/{page-id}/photos?url={image-url}&message=your message

I'm still trying to add a link as well. If someone managed to do it, that will be helpful to share.

Jimmy
  • 101
  • 2
  • 5
3

If you need to post post images with the message you have to provide the link of the URL where the image is available.

For reference you can check this link on Facebook documentation,

https://developers.facebook.com/docs/graph-api/reference/v2.1/user/feed#publish

As you told you have not seen any parameter for image, click on link parameter to see further. This will clear your doubt because for posting image, with text, or link you have to use this API.

If you want to publish only image then this API will work.

https://developers.facebook.com/docs/graph-api/reference/v2.1/user/picture

updated link:

https://developers.facebook.com/docs/graph-api/reference/v2.12/post

Elshan
  • 7,339
  • 4
  • 71
  • 106
Atul Jindal
  • 946
  • 8
  • 8