如何使用 Facebook PHP SDK 获取图片 url

How to get the picture url using the Facebook PHP SDK

我使用的是最新版本的 Facebook PHP SDK(第 4 版)。我终于想出了如何在我的 PHP 代码中使用它。下面是我的代码。

        $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'] = ;

我指定什么来接收图片 URL,我请求了它?

此外,我手动打开了名为 GraphUser.php 的 fb php sdk 文件,只是想看看我是否可以自己找到 属性。在 pastebin 上。

http://pastebin.com/K6Xg0MjN

如您所见,GraphUser 对象不包含任何处理图片的属性,那么我从哪里获取图片呢?

请并感谢阅读

这不是用户对象的一个​​名为 picture 的字段。这是一个优势:

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');