FQL get last 50 photos query returns error

2019-09-06 20:12发布

问题:

How can i get the last 50 photos uploaded by all my friends ?

I try to run this query in FQL:

SELECT pid, src 
FROM photo 
WHERE 
owner IN (SELECT uid1 FROM friend WHERE uid2=me())
OR pid IN (
     SELECT pid FROM photo_tag 
     WHERE subject in (SELECT uid1 FROM friend WHERE uid2=me())
) 
ORDER BY created DESC
LIMIT 50 OFFSET 0

I need to get last 50 photos from all my friends or that my friends where tagged in...

when i run it in the API Explorer i get an error:

{
  "error": "Request failed"
}

I know i have sufficen permission becus when i run these 2 query i get results:

SELECT pid, src FROM photo WHERE owner =(me())

and

SELECT uid1 FROM friend WHERE uid2=me()

EDIT: I have also tried this ..

SELECT pid, caption, aid, owner, link, src_big, src_small, created, modified FROM photo 
WHERE owner IN  ( SELECT uid1 FROM friend WHERE uid2=me() )
and created >= 1377800559 
ORDER BY created DESC LIMIT 100

how can i get more information ? is it not possible to run such a query ?

回答1:

Finnaly !!! Last Posted Photos from all friends...

SELECT pid, src, src_small, src_big, target_id, created, backdated_time 
FROM photo where pid in (
    SELECT attachment.media.photo.pid
    FROM stream 
    WHERE filter_key IN (SELECT filter_key FROM stream_filter WHERE uid=me()) AND type = 247
)

as you can see my initial approach was all wrong ... it is actually required to use the stream table to get the latest posts.. then it could be filtered to get only photos posted and use their pid to get all the required info !!! YAY!

I hope it helps other that encounter the same issue..



回答2:

I'm not sure why, but a weird thing is happening here. When I tried your query- I got

Request failed

Then, after digging a bit I replaced SELECT uid2 FROM friend WHERE uid1 = me() with the IDs and the query worked!

So, as a solution you could first try to get the list of friends with :

SELECT uid2 FROM friend WHERE uid1 = me()

Then use this result in your query as-

SELECT pid, src 
FROM photo 
WHERE 
  owner IN (ID1, ID2, ID3 ...)
  OR pid IN (
     SELECT pid FROM photo_tag 
     WHERE subject IN (ID1, ID2, ID3 ...)
  ) 
ORDER BY created DESC
LIMIT 50 OFFSET 0

Strange, but this'll work!