Facebook SDK使专辑和照片无法正常工作

时间:2012-03-27 14:15:29

标签: php facebook

所以,知道它会返回albums..album名称的数据,但我还需要专辑的封面图片,以及每张专辑的照片,这是我当前的代码:

function get_albums($facebook)
{
    $fb_user = $this->getFbUser($facebook);
    $myalbums = $facebook->api('/me/albums');
    return $myalbums["data"];
}

function getFbUser($facebook)
{
    $fb_user = $facebook->getUser(); //gets user id

    if(is_null($fb_user))
    {
            header("Location:{$facebook->getLoginUrl(array('req_perms' => 'user_status,publish_stream,user_photos'))}");
            exit;
    }
    return $fb_user;
}

function getFb()
{
    $facebook = new Facebook(array(
        'appId' => 'secret',
        'secret' => 'secret',
        'cookie' => true,
        ));
    return $facebook;
}

1 个答案:

答案 0 :(得分:0)

我解决了它:

/*
   $albID pass the album ID
*/
function get_fbimages($facebook,$albID = null)
{
$fb_user = $this->getFbUser($facebook);
$myimages = $facebook->api("/$albID/photos");
return $myimages;
}