Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Post message with picture to facebook page/feed using graph api

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

like image 269
Vladimir Mikhaylovskiy Avatar asked Aug 30 '14 06:08

Vladimir Mikhaylovskiy


People also ask

Can you post to Facebook using API?

The Graph API is the primary way to get data into and out of the Facebook platform. It's an HTTP-based API that apps can use to programmatically query data, post new stories, manage ads, upload photos, and perform a wide variety of other tasks.

How do I make a graph API on Facebook?

Go to Tools – Graph API Explorer to generate Access Tokens for various kinds of API that you would like to use in your app. Choose the app and kind of token you need in the drop down menus in the left part of the screen. Then click “Generate Access Token”.

How do I get Facebook Page Insights on graph API?

/* make the API call */ FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"{object-id}/insights/{metric}" parameters:params HTTPMethod:@"GET"]; [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { // Handle the result }];


1 Answers

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

like image 124
Axel Amthor Avatar answered Oct 18 '22 14:10

Axel Amthor