Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upload a picture for an event using the Facebook Graph API?

Tags:

php

facebook

I would like to know how to add a picture to an event using the Facebook Graph API. I have seen this question and tried some variations on that theme, without any success. The official documentation doesn't seem to make any mention of it.

I'm using PHP for this particular project and I've looked at the PHP SDK source code, which is not helpful in any way. Requesting metadata for pictures using https://graph.facebook.com/eventid/picture?metadata=1&access_token... doesn't seem to be recognized, so no help there either.

Has anyone come across some example or documentation on how to do this? (don't care about which language it is in)

like image 536
Thorarin Avatar asked May 12 '10 18:05

Thorarin


2 Answers

This is supported by the Graph API, however it is poorly documented. You need to send the image as multipart attachment in the POST request. Try this:

curl -F 'access_token=...' \
-F 'name=Test Event' \
-F 'description=The description' \
-F 'start_time=2012-09-01T12:00:00+0000' \
-F '@file.jpg=@/path/to/image.jpg' \
https://graph.facebook.com/me/events

That event should have a picture.

They have recently added support for this to the PHP SDK.

I've forked their python-sdk and added multipart support, and added a simple put_event method that accepts a url for a picture, as well as the usual params.

like image 132
Michael Scheibe Avatar answered Sep 28 '22 03:09

Michael Scheibe


While searching for the problem, i found following links which might be of interest.

http://wiki.developers.facebook.com/index.php/PHP

http://wiki.developers.facebook.com/index.php/Photos.upload

http://developers.facebook.com/docs/reference/rest/

In last link, check "Publishing methods" and "Dashboard API methods". It has methods for Video and Photo uploading.

Photo: http://developers.facebook.com/docs/reference/rest/photos.upload

Video: http://developers.facebook.com/docs/reference/rest/video.upload

--------------EDIT---21st May,2010,8:58 PM IST---------------------

Check this thread out, it shows photo uploding code in PHP using graph API which you mentioned.

Upload Photo To Album with Facebook's Graph API

I hope this helps.

thanks.

like image 25
Parth Avatar answered Sep 28 '22 03:09

Parth