Reputation: 33
I am not sure as to why my request isn't pulling correctly the data I'm seeking. I am new to FQL and not sure how to exactly incorporate the WHERE IN
in this format. I'm trying to avoid using a facebook object.
The purpose of my query is to get the facebook user_id
s of those who have liked on the last 100 posts.
$fql_multiquery_url = 'https://graph.facebook.com/fql?q='
. '"post+ID":"SELECT+post_id+FROM+stream+WHERE+source_id=6979393237+LIMIT+100",'
. '"like+ID":"SELECT+user_id+FROM+like+WHERE+post_id+IN+#postID"}'
. '&access_token=' . $access_token;
Upvotes: 1
Views: 97
Reputation: 31479
Why not the following:
$fql_query_url = 'https://graph.facebook.com/fql?q=SELECT+user_id+FROM+like+WHERE+post_id+IN+(SELECT+post_id+FROM+stream+WHERE+source_id=6979393237)+LIMIT+100&access_token=' . $access_token;
I don't see the need for two separate queries if you can use query nesting (for a reference look here: https://developers.facebook.com/docs/technical-guides/fql/#query)
Upvotes: 0
Reputation: 22903
Your FQL multi-query looks senseful, but why doesn't it work?
#this
is not a variable (but a complete result set containing several rows), so you need to write an additional query (using SELECT
) to get the interesting row (say post_id
).{
.FQL query:
{ "posts":"SELECT post_id FROM stream WHERE source_id=6979393237 LIMIT 100", "likes":"SELECT user_id FROM like WHERE post_id IN (SELECT post_id FROM #posts)" }
PHP code:
$fql_multiquery_url = 'https://graph.facebook.com/fql?q={'
. '"posts":"SELECT+post_id+FROM+stream+WHERE+source_id=6979393237+LIMIT+100",'
. '"likes":"SELECT+user_id+FROM+like+WHERE+post_id+IN+(SELECT+post_id+FROM+#posts)"}'
. '&access_token=' . $access_token;
Upvotes: 1