Skip to content

Instantly share code, notes, and snippets.

@dommmel
Created June 27, 2012 16:24
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 dommmel/3005218 to your computer and use it in GitHub Desktop.
Save dommmel/3005218 to your computer and use it in GitHub Desktop.
Takes an array of facebook graph object ids and assembles them into one batch request
def fb_batch_request(id_array, access_token)
raise "Array to long (>20)" if id_array.length > 20
queries = id_array.map { |id| {:method => 'GET', :relative_url => "#{id}"} }
route = "https://graph.facebook.com/?access_token=#{access_token}&batch=#{URI.encode(queries.to_json)}"
HTTParty.post(route)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment