Skip to content

Instantly share code, notes, and snippets.

@jamesladd
Created September 29, 2011 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesladd/1249873 to your computer and use it in GitHub Desktop.
Save jamesladd/1249873 to your computer and use it in GitHub Desktop.
Post picture to wall on facebook
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