drf65218 2015-03-06 12:57
浏览 19
已采纳

如何使用Facebook PHP SDK获取图片网址

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.

http://pastebin.com/K6Xg0MjN

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

  • 写回答

1条回答 默认 最新

  • doukan5332 2015-03-07 08:25
    关注

    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');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了