$queries = '{"query1":"SELECT pid, src, link, caption, like_info, created FROM photo WHERE aid in ( SELECT aid FROM album WHERE owner = me() AND type = \"profile\" AND name = \"Profile Pictures\" ORDER BY created ASC LIMIT 1)","query2":"SELECT pid, src, link, caption, created, like_info FROM photo WHERE aid in ( SELECT aid FROM album WHERE owner = me() AND type = \"profile\" AND name = \"Profile Pictures\" ORDER BY created DESC LIMIT 1)"}';
$multiquery = "https://api.facebook.com/method/fql.multiquery?queries=" . urlencode($queries) . "&format=json&" . $access_token;
$res = json_decode(file_get_contents($multiquery), TRUE);
But when execute a two single queries, it is working fine. What is the problem here?
I am just trying to fetch the first and the last profile photo
A few comments:
The best way to do this is with the PHP SDK and not with
file_get_contents.You are using the old REST API url, which is deprecated. You should be using the Graph API url:
https://graph.facebook.com/fql?q=Does your
$access_tokenvariable include the&access_token=piece of the query string?Finally, to keep your queries straight, I’ve found the best way is to add these as elements of an array with the query name as the key, e.g.:
$fql['query1'] = 'SELECT ...'and then usejson_encode(preg_replace('/\s+/', ' ', $fql))to combine them into error-free json.