Post image on facebook page / feed using api chart

I am trying to post a single image post via facebook API and I cannot. In the new documentation https://developers.facebook.com/docs/graph-api/reference/v2.1/user/feed there is no field for the image.

If I try to use the "object_attachment" field, only a small sketch appears, and the post - style, as a shared link.

If I try to use the picture field and use the URL of the photo on the Internet, the result will be the same. I canโ€™t post a โ€œpictureโ€ from local, like here:

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

an error appears: "The image URL is not formatted properly."

I just used a free web application to make a photo message and the result is fine (see attached image)

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

enter image description here

+6
source share
2 answers

if you want to send a photo to FB (for example, to albums) and text and publish it on the timeline, you need to upload the photo to FB. Not as an attachment with an external URL, but as binary data sent to the FB.

Take a look

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

and inside this source field

+4
source

If you need to send a message with a message, you must provide a link to the URL where the image is available.

For reference, you can check this link in the Facebook documentation,

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

As you said, you did not see any parameters for the image, click on the parameter link to see further. This will eliminate your doubt because you must use this API to post an image with text or a link.

If you want to publish only the image, 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

+3
source

Source: https://habr.com/ru/post/974577/


All Articles