Reputation: 18103
{
"query1": "SELECT aid, cover_pid, name, created FROM album
WHERE owner = 166125753465316 AND name != \'Wall Photos\' ORDER BY created DESC LIMIT 3",
"query2": "SELECT pid, src, src_small, src_big, caption FROM photo
WHERE aid IN (SELECT aid FROM #query1) ORDER BY created DESC LIMIT 5"
}
With above in $queries, and then:
$param = array(
'method' => 'fql.multiquery',
'queries' => $queries,
'callback' => ''
);
$fqlResult = $facebook->api($param);
var_dump($fqlResult);
returns me an empty array? What have I done wrong?
I would like to grab albums where owner =... , and get 5 photos from each albums.
I can do this with single queries, but then it really takes long time for the page to load!
Upvotes: 3
Views: 937
Reputation: 11104
IN this case i think you not need multiquery you just change like this
SELECT pid, src, src_small, src_big, caption FROM photo
WHERE aid IN (SELECT aid FROM album WHERE owner = me() ORDER BY created DESC )
ORDER BY created DESC LIMIT 5
you cal also use this GRAPH API
me?fields=albums.fields(cover_photo,created_time,photos.limit(5).fields(link))
here is link
Upvotes: 1
Reputation: 99
Try to remove newline in your query just use spaces as separator.
Try this edited fql
{
"query1": "SELECT aid, cover_pid, name, created FROM album WHERE owner = 166125753465316 AND name != \'Wall Photos\' ORDER BY created DESC LIMIT 3",
"query2": "SELECT pid, src, src_small, src_big, caption FROM photo WHERE aid IN (SELECT aid FROM #query1) ORDER BY created DESC LIMIT 5"
}
Upvotes: 1
Reputation: 11852
I just tried this, and substituting me()
for the ID in your query, it works. When I try to look for your id, 166125753465316, it throws an "Unsupported get request error". This could be your problem.
I was able to get data using the PAGE_ID in your comment with a valid user or app access token.
A couple of other comments: You should be using object_id
instead of aid
and pid
. These are on track to be deprecated.
Second, this query is going to only return the 5 most recent photos from the three albums you've returned. To get 5 photos each, you'll need to do something like this:
{
"albums": "SELECT object_id, cover_object_id, name, created FROM album
WHERE owner = me() AND type != 'wall' ORDER BY created DESC LIMIT 3",
"album1": "SELECT object_id, src, src_small, src_big, caption FROM photo
WHERE album_object_id IN (SELECT object_id FROM #albums LIMIT 1 OFFSET 0)
ORDER BY created DESC LIMIT 5",
"album2": "SELECT object_id, src, src_small, src_big, caption FROM photo
WHERE album_object_id IN (SELECT object_id FROM #albums LIMIT 1 OFFSET 1)
ORDER BY created DESC LIMIT 5",
"album3": "SELECT object_id, src, src_small, src_big, caption FROM photo
WHERE album_object_id IN (SELECT object_id FROM #albums LIMIT 1 OFFSET 2)
ORDER BY created DESC LIMIT 5"
}
Upvotes: 1
Reputation: 1202
Have you tried this graph api query -
USER_ID?fields=albums.fields(name,photos.limit(5).fields(id,name),id,cover_photo,created_time)
This comes from the recently introduced graph api field expansion feature - https://developers.facebook.com/docs/reference/api/field_expansion/
Upvotes: 1