Reputation: 134
I want to use facebook's graph api to retrieve a page's photos. Here's the call I'm using:
'https://graph.facebook.com/'. $pageID .'/photos?access_token='. $page_access_token
For some reason this call returns an empty data set. I am using a page access token not an users, and the user is the admin of the page I'm trying to retrieve photos from. The page ID is correct since when I use this call to get the page's events it works well. Am I using the wrong call?
Upvotes: 2
Views: 3380
Reputation: 11
First of all, it's 3D{page_id})
and not 3D%{page_id})
. That is, no extra %.
Secondly, it seems to retrieve anything by photos uploaded by others.
Upvotes: 1
Reputation: 146
Sometimes you're unfortunately stuck using FQL calls to get this type of information. Facebook has a lot of inconsistencies with how page data is handled -- I won't get into these, but what you're looking to do can be found here: How to use Facebook graph API to retrieve fan photos uploaded to wall of fan page?
Here's a PHP example:
$photoQuery = urlencode('SELECT pid,owner,src_small,src_big FROM photo WHERE aid IN ( SELECT aid FROM album WHERE owner = your_page_id)');
$photoFQL = 'https://api.facebook.com/method/fql.query?query='.$photoQuery .'&access_token='.$accessToken.'&format=json';
$photoResults = file_get_contents($photoFQL);
You'll end up with a url like this you can test with:
https://api.facebook.com/method/fql.query?query=SELECT%20pid%2Cowner%2Csrc_small%2Csrc_big%20FROM%20photo%20WHERE%20aid%20IN%20(%20SELECT%20aid%20%20FROM%20album%20%20WHERE%20owner%20%3D%{page_id})&access_token={access_token}&format=json
Replacing the {page_id} and {access_token} with your own, of course. I tested this and it showed my Community/Fan Page's photos in a JSON response. Good luck.
Upvotes: 1