facebookfacebook-graph-apifacebook-fqlfql.multiquery

Any way to use elements of FQL attachment media array in multiquery?


I need to get the list of comments for each item in a user's news feed including comments for any media in the feed items.

I'm trying to avoid multiple FQL query roundtrips, so I'd like to use multiquery.

I can get the comments for each post_id in the feed:

{
  posts: 'SELECT post_id, attachment FROM stream WHERE filter_key = "nf"',
  post_comments: 'SELECT post_id, fromid, text FROM comment WHERE post_id IN (SELECT post_id FROM #posts)'
}

However, there doesn't seem to be a way to reference content in the media elements so I can request the comments for media fbids, e.g.:

  photo_comments: 'SELECT object_id, fromid, text FROM comment WHERE object_id in (SELECT attachment.media.fbid FROM #posts)'

This question (How to query FQL Stream by Attachment.Media.Type?) is very similar, but the answer was a bit uncertain & wasn't accepted.

Any suggestions or definitive answer?


Solution

  • Figures -- once I posted the question, I came across an answer to another question (http://facebook.stackoverflow.com/questions/8003581/get-photos-from-stream) that gave me what I needed:

    photo_comments: 'SELECT object_id, fromid, text from comment where object_id in (SELECT attachment.media.photo.fbid from #posts)'  
    

    The example in my answer was a generic description, but turned out to be close to the actual technique (with the photo object missing in the path).

    Hope this helps somebody else doing a similarly narrow search.