-2

I want to find all the feeds with comments an also the profile image of the the user who commented on the posts. I found that it can be done through batch request. Now i am doing like this which fires lots of API request.

@facebook = FacebookToken.find_by_id(token.id)
@graph = Koala::Facebook::API.new(@facebook.access_token)
@results = @graph.get_connections("me", self.content)
@results.each do |post|
     post['comments']['data'].each do |comment|
         commnentor_image = @graph.get_picture(comment["from"]["id"])
     end
end

How can i get these into a single batch request so that it will give me all the posts with comments with the commentor image.

Thank's

tripurari
  • 71
  • 7

1 Answers1

1

The batch request will definitely speed up your queries, but I would consider looking at FQL as well - FB documentation states that an FQL multiquery is even faster than batch queries! Better yet, you can batch your FQL multiqueries....

You can try this for the batch (see the Koala Wiki for more info) :

@graph.batch do |batch|
   r = batch.get_connections("me", self.content)
   r.each do |post|
      post['comments']['data'].each do |comment|
         commnentor_image = @graph.get_picture(comment["from"]["id"])
     end
   end

Check out the FQL docs for more info...

To get you started:

@graph.fql_multiquery(SELECT .....your FQL Query)
abhir
  • 1,059
  • 1
  • 9
  • 25