Recently I’m working with Facebook batch requests using PHP. Now, I’m trying to get the names of the people who select an option in Facebook questions but also get the option they’ve selected. Having a relation of this with a simple query using FQL is difficult so I tried to separate them
Using this:
SELECT voter_id FROM question_option_votes WHERE option_id IN (SELECT id from question_option WHERE question_id = "...")
AND
SELECT uid, username, ... FROM user WHERE uid IN ({result=aliasOfTheLastRequest:$.data.*.voter_id)
But I got nothing! I know the limit of request using batch is 20.
$fql = 'method/fql.query?query=SELECT voter_id FROM question_option_votes WHERE option_id IN (SELECT id from question_option WHERE question_id = "252339054834206") LIMIT 20';
$batch = array(
array(
'method' => 'GET',
'name' => 'getfriends',
'relative_url' => str_replace(' ', '+', $fql),
'omit_response_on_success' => false // Also changed to true
),
array(
'method' => 'GET',
'relative_url' => 'method/fql.query?query=SELECT+uid,+username,... FROM+user+WHERE+uid+IN+({result=aliasOfTheLastRequest:$.data.*.voter_id) ' // I also tried this '?ids={result=getfriends:$.data.*.voter_id}'
)
);
$data = $this->facebook->api('/?batch=' . json_encode($batch) . '&access_token=' . $access_token, 'POST');
When I print $data, I got the data result of the first query but not of the second. For the second I got and empty array; and using the other option: “Cannot specify an empty identifier”; so I’m not getting the results of the first query into the second one.
Am I doing something wrong?
Just replace
$.data.*.voter_idwith$.*.voter_id(fql.querydoesn’t returndataobject, justbody)