user1085195
user1085195

Reputation: 395

get list of all facebook albums using graph api

I am using facebook php sdk 3.2 I am using the url "https://graph.facebook.com/user_id/albums?access_token=token to get all the albums of a user. But for some users, it is giving blank results like

{
   "data": [
   ]
}

Why is this happening, and how do i get all the albums of a user?

The code I am using is

$this->facebook=new Facebook(array(
                            'appId' => $appId,
                            'secret' => $appSecret,
                            'cookie' => true
                        ));

if(is_null($this->facebook->getUser()) || $this->facebook->getUser()==0)
    $this->askForLogin();

$this->accessToken = $this->facebook->getAccessToken();

$feedURL = "https://graph.facebook.com/".$this->facebook->getUser()."/albums?access_token=".$this->accessToken;

$albumData = file_get_contents($feedURL);

Upvotes: 2

Views: 6876

Answers (2)

user1085195
user1085195

Reputation: 395

it was an issue of the user's settings where it blocked all apps to view his photos. This is solved now

Upvotes: 0

yacon
yacon

Reputation: 1122

do you ask for permission "user_photos"?

If the user blocks the photos you need to ask for that permission at the auth process.

You can read more about permission here: http://developers.facebook.com/docs/reference/login/

Upvotes: 3

Related Questions