douchui1488 2011-07-13 12:22
浏览 62
已采纳

使用Graph API PHP SDK从特定的Facebook相册中获取所有图像

Hi I'm trying to grab all pictures from a specific album (always the same hardcoded id). I'm using the Graph API PHP SDK from Facebook. This is my code:

<?php
require 'phpfiles/facebook.php';

    $facebook = new Facebook(array(
    'appId'  => 'aaaa',
    'secret' => 'bbbb',
    'cookie' => true
));

$user_profile = $facebook->api('/1881235503185/photos?access_token=cccc');
var_dump($user_profile);

The var_dump output:

array(1) { ["data"]=> array(0) { } }
  • 1881235503185 is the id of MY album that is not restricted, it's open to everybody
  • the access_token is the token I get from my application page for my fb id. I don't get oauth errors.
  • I have the permissions (user_photos) and tryed to add a dozen of other permissions.
  • When I try it with the Graph API Explorer it works to.

When I use the Javascript SDK it works fine...

FB.api('/1881235503185/photos?access_token=cccc', function(response) {
    alert(response.data[0].name);
});

Output: Diep in de put

Am I forgetting something?

  • 写回答

3条回答 默认 最新

  • dongmi5177 2011-07-14 06:52
    关注

    I got it! It should be:

    $user_profile = $facebook->api('/1881235503185/photos', array('access_token' => 'cccc'));
    

    With the new Facebook PHP SDK it should be:

    $albumjson = $facebook->api('/1881235503185?fields=photos');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?