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.

3 Answers 3

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
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!

6
  • 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
    Apr 5, 2012 at 2:09
  • Oh and I tried your suggestion and the Explorer returns the error, "Requires upload file"
    – Chelonian
    Apr 5, 2012 at 2:32
  • Hmm. I just tried a post to /me/photos, with a 'url' param - uploaded fine. WHat endpoint are you trying to upload to? Apr 5, 2012 at 3: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
    Apr 5, 2012 at 3:38
  • 3
    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 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. 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! Apr 5, 2012 at 3:54
1

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

Posting with graph explorer Hope this helps.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.