Facebook Graph API will not give me picture data

后端 未结 6 759
傲寒
傲寒 2021-01-12 22:59

Using PHP 5.2.11 and the new facebook graph code...

If I call

$facebook->api(\"/me\");

I get a proper response:

array
  \'id\' =>          


        
相关标签:
6条回答
  • 2021-01-12 23:22

    There is an even simpler way, using the provided facebook api, just call:

    $facebook->api("/me?fields=picture");

    This will make your code simpler and more elegant.

    0 讨论(0)
  • 2021-01-12 23:23

    While using $facebook->api("/me?fields=picture"); does work, you won't be able to pass parameters such as width or type. Instead try the following:

    $facebook->api('/me/picture?redirect=false');
    

    This worked for me and will also allow you to pass parameters.

    0 讨论(0)
  • 2021-01-12 23:26

    You may not even need to do an API call... use this on your frontend:

    <img src="//graph.facebook.com/USER_ID/picture?type=square" />
    

    Read more here: http://developers.facebook.com/docs/reference/api/#pictures

    0 讨论(0)
  • 2021-01-12 23:35

    As an addition to betaman's answer, you can pass the parameters in a separate array like so:

    $aResponse = $oFacebook->api('/me', array(
        'fields' => 'picture',
        'type' => 'large'
    ));
    
    0 讨论(0)
  • 2021-01-12 23:36

    I just went to my "/me/picture" in the browser and it redirected me to a static image on one of Facebook's CDN servers. Perhaps the redirect is throwing a wrench in your api call.

    0 讨论(0)
  • 2021-01-12 23:40

    Well I guess the best answer I've found is to call http://graph.facebook.com/USER_ID?fields=picture to get the picture URL. Its to bad they don't document things like this on their API especially when its obvious this is broken for so many people.

    0 讨论(0)
提交回复
热议问题