Created
September 29, 2011 02:47
-
-
Save jamesladd/1249873 to your computer and use it in GitHub Desktop.
Post picture to wall on facebook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
to create Facebook events with a picture through the Graph API you need to use a multipart post request and give the image the key "picture". | |
This is not documented. At all. Anywhere. Except here. | |
To do this in Koala, you can use a line like this: | |
graph = Koala::Facebook::GraphAPI.new( oauth.get_app_access_token ) | |
graph.put_object( APP_ID, "events", { | |
:name => "Some event", | |
:start_time => Time.now.to_s, | |
:description => "Facebook API docs suck", | |
:picture => Koala::UploadableIO.new("public/images/gamej_logo.png") | |
}) | |
The UploadableIO object causes the underlying Koala request method to use multipart POST - also undocumented - and use the correct key name. | |
For anyone else suffering with Koala, you may need to use the graph_call method, which takes the object ID you want to mess with, and the arguments you want to post - unlike the put_object method, which takes the parent object ID and the connection you want to post to. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment