Use Graph API Explorer to post a photo

Go To StackoverFlow.com

3

My ultimate goal is to do this programmatically, but as a sanity check I'm trying to just post an uploaded photo (from my computer) to a Facebook page using the Facebook Graph API Explorer. I have the access token and photo_upload and publish_stream permissions.

I just don't understand what to do to indicate where the photo is. How can I do it?
Thanks.

2012-04-04 22:14
by Chelonian


3

I don't think the Graph API explorer tool supports file upload, so you won't be able to use it to check your uploads.

Facebook accepts a url param for image uploads - point that to a full image url, and Facebook should pick it up. Since it's just a string, you can use the Explorer for that.

However, Facebook should come back with reasonable errors for photo uploads - I'd start coding rather than worry about the explorer tool!

2012-04-05 01:00
by Tom Waddington
Unfortunately, the error I get when I try to use Facepy (to use Python to interact with FB) is "Error: (#1) An unknown error occurred". This is not an error that informs me of anything - Chelonian 2012-04-05 02:09
Oh and I tried your suggestion and the Explorer returns the error, "Requires upload file - Chelonian 2012-04-05 02:32
Hmm. I just tried a post to /me/photos, with a 'url' param - uploaded fine. WHat endpoint are you trying to upload to - Tom Waddington 2012-04-05 03:20
I'm trying to have a photo appear on one's "wall", I guess. Whatever one would use to share with others (I have barely used FB). Could you be as specific as possible on what you did on the Explorer page and where you wrote what? Total newb here. Thanks - Chelonian 2012-04-05 03:38
Sure. Head to the explorer. Select your app from the drop down in the top right. Choose "POST" as the method. Type /me/photos as the endpoint (so the form reads POST http://graph.facebook.com/me/photos). Then, click Add a field. Set the name to url, and the value to a full image url (e.g. https://appharbor.com/assets/images/stackoverflow-logo.png). Hitting submit on this should upload the image to Facebook. It'll be shared on your wall, and appear in the default album for your app. Hope that helps - Tom Waddington 2012-04-05 03:54
Thanks, that did it! (Now on to why Facepy won't work for me... - Chelonian 2012-04-05 04:15


4

Use curl with the -F and "source=" flags and it should work. Here is a code snippet from one of our applications (we construct this curl command from PHP):

curl -F 'access_token=xxxxxx' -F 'source=@/path/to/image.jpg' 
-F 'message=' -F 'privacy={"value": "EVERYONE"}' 
https://graph.facebook.com/FB-ALBUM-ID/photos
2012-04-05 00:33
by Shreeni


1

I managed to post images from Graph API explorer using this!

Posting with graph explorer Hope this helps.

2016-08-01 10:25
by Benedict
This doesn't work. Try on explorer - hkchakladar 2017-08-06 18:24
Ads