lisovaccaro
lisovaccaro

Reputation: 33946

Can't get Facebook's user photos with php

I'm trying to get the user photos, but I cannot get the user's photos data.

I'm trying this:

$photos = $facebook->api('https://graph.facebook.com/'.$profileFID.'/photos?access_token='.$access_token);
print_r($photos);

I'm sure the URL is correct since pasting it in the browser shows the photos array. However when I try to print the array to check if I got it I get only this:

( [id] => https://graph.facebook.com/1409006586/photos ) 

How can I get the full array with the user photos?

Upvotes: 0

Views: 623

Answers (2)

user1760979
user1760979

Reputation:

https://graph.facebook.com/1409006586/photos

replace photo by picture

ex https://graph.facebook.com/4/picture

Upvotes: 0

ifaour
ifaour

Reputation: 38115

The Facebook SDK will take care of constructing the url for you (and append the access_token), you just need to build the query:

$photos = $facebook->api('me/photos');

If the user is not currently logged in but you have the access_token, then use:

$photos = $facebook->api($profileFID.'/photos', 'get', array('access_token'=>$access_token));

P.S: always put your queries in a try...catch blocks

Upvotes: 2

Related Questions