Facebook Graph API不会给我图片数据

Bra*_*row 6 php facebook graph

使用PHP 5.2.11和新的facebook图形代码......

如果我打电话

$ facebook-> API( "/我");

我得到了适当的回应:

array
  'id' => string '10700210' (length=8)
  'name' => string 'Brandon Renfrow' (length=19)
  'first_name' => string 'Brandon' (length=7)
  'middle_name' => string '✫' (length=3)
  'last_name' => string 'Renfrow' (length=7)
  'link' => string 'http://www.facebook.com/brenfrow' (length=32)
  'about' => string 'Spiritual birthday: 1/22/2005' (length=29)
  ...
  ...
Run Code Online (Sandbox Code Playgroud)

但是,如果我打电话

$facebook->api("/me/picture");
Run Code Online (Sandbox Code Playgroud)

我总是得到一个回应:

null
Run Code Online (Sandbox Code Playgroud)

有人知道为什么吗?

Bra*_*row 14

好吧,我想我找到的最佳答案是调用http://graph.facebook.com/USER_ID?fields=picture来获取图片网址.它很糟糕,他们没有在他们的API上记录这样的事情,特别是当很多人明显这样做时.

  • 谢谢你搞清楚这一点.Facebook Graph API可能是我曾经使用过的设计最差甚至更糟糕的API之一. (4认同)

eno*_*rev 8

作为除了betaman答案,可以传递的参数在像这样一个单独的数组:

$aResponse = $oFacebook->api('/me', array(
    'fields' => 'picture',
    'type' => 'large'
));
Run Code Online (Sandbox Code Playgroud)


Chr*_*cob 7

您甚至可能不需要进行API调用...在您的前端使用此功能:

<img src="//graph.facebook.com/USER_ID/picture?type=square" />
Run Code Online (Sandbox Code Playgroud)

在这里阅读更多内容:http://developers.facebook.com/docs/reference/api/#pictures