2012-03-27 78 views
0

因此,知道它會返回相冊數據。相冊名稱,但我也需要該相冊的封面圖片以及每張相冊的照片,這裏是我當前的代碼:Facebook SDK讓相冊和照片無法正常工作

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; 
} 

回答

0

我解決了它:

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