Chanchal Raj
Chanchal Raj

Reputation: 4306

Get Logged In FB User's albums

I get an empty array when I request logged in facebook user's photo albums. Following is the code:

FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                                      initWithGraphPath:[NSString stringWithFormat:@"me/albums"]
                                      parameters:nil
                                      HTTPMethod:@"GET"];
        [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                              id result,
                                              NSError *error) {
            NSLog(@"Results: %@",result);
        }];

NSLog results:

Results: {
data =     (
);

While logging in, I have set the permissions as @"basic_info",@"user_photos",@"friends_photos"

Here is code to log in:

FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init];
    [loginManager logInWithReadPermissions:@[@"basic_info",@"user_photos",@"friends_photos"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
        [appDelegate getFacebookUserInfo];
        NSLog(@"Granted Perm: %@ Declined Perm: %@",[result grantedPermissions],[result declinedPermissions]);
    }];

The NSLog prints:

    Granted Perm: {(
    email,
    "contact_email",
    "public_profile"
)} Declined Perm: {(
)}

Upvotes: 3

Views: 311

Answers (1)

Chanchal Raj
Chanchal Raj

Reputation: 4306

  1. When Logging in @"friends_photos" is not needed.
  2. @"user_photos" permission will do the job

As per Facebook's official documentation: If your app requests this permission Facebook will have to review how your app uses it.

That is the reason, @"me/albums" returned empty array. Meanwhile, your app goes for review to Facebook, you can get a user's album. But the user must be one of users in your Facebook App Dashboard's Roles section.

Upvotes: 3

Related Questions