Reputation: 29
I'm using the latest version of the Facebook PHP SDK (version 4). I finally figured out how to use it in my PHP code. Below is my code.
$user_profile = (new FacebookRequest($this->session, 'GET', '/me/?fields=id,first_name,last_name,picture,timezone,gender,link'))->execute()->getGraphObject(GraphUser::className());
$outputArray[$i]['first_name'] = $user_profile->getFirstName();
$outputArray[$i]['last_name'] = $user_profile->getLastName();
$outputArray[$i]['pictureURL'] = ;
What do i specify to receive the picture URL, i requested it?
Also, i manually opened up the fb php sdk file called GraphUser.php just to see if i can find the property myself. here it is on pastebin.
As you can see, the GraphUser object doesn't contain any properties that deal with the picture, so where do i get the picture then?
please and thanks for reading
Upvotes: 0
Views: 1159
Reputation: 1570
The isn't a field called picture
for the user object. It's an edge:
https://developers.facebook.com/docs/graph-api/reference/v2.2/user/picture
$picture_info = (new FacebookRequest($this->session, 'GET', '/me/picture'))->execute()->getGraphObject();
$outputArray[$i]['pictureURL']=$picture_info->getProperty('url');
Upvotes: 2