0

I am using Facebook SDK latest version 4.3 in my code. My task is that I have to fetch the complete album of user named Profile Pictures from Facebook's following path: UserProfile-> Photos-> Albums-> Profile Pictures.

To achieve this I have passed the permission for @"public_profile", @"user_photos", etc...

I have searched many links on SO & tried almost all the suitable answers suggested by geeks.

I tried things given here, here, and a lot more...

In my current scenario, I am getting Users Profile Picture (Current), but I need all pictures stored in his Profile Pictures Album. If anyone has any idea, please help.

Community
  • 1
  • 1

2 Answers2

0

There's no way to do this in one request as far as I know. You'll need to do two things:

  1. Request the albums of the user, and parse the results for the album "Profile Pictures"

    GET /me/albums?fields=id,name&locale=en_US

This returns an JSON like this:

{
  "data": [
    {
      "id": "442898331243456464", 
      "name": "Profile Pictures", 
      "created_time": "2010-12-12T13:35:29+0000"
    }
    ...
  ], 
  "paging": {
    "cursors": {
      "after": "NDQyODk4MzMxMjQz", 
      "before": "MTAxNTA5MjQyNDQ4NDYyNDQ="
    }
  }
}
  1. Grab the id of the album with the name "Profile Pictures", and request the photos edge like this:

    GET /442898331243456464/photos

You will receive a JSON obect with the profile pictures. It's possible that you need to paginate through the results if there are more than 25 photos.

Tobi
  • 31,405
  • 8
  • 58
  • 90
  • What if the Profile Pictures album not available in the first set of result and it would be multiple calls again to paginate through and check for profile pictures ! – Tushar May 28 '15 at 07:48
  • Yes, but there's no other way. Pagination is easy as well, and I already wrote that in my answer. Read the docs. You didn't write anything about a solution in your answer, do you actually have another idea? – Tobi May 28 '15 at 07:55
0

first login in facebook after that write following code by which you can get user profile pic from facebook .

  NSMutableDictionary* parameters = [NSMutableDictionary dictionary];
            [parameters setValue:@"id,name,email,picture" forKey:@"fields"];

            [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:parameters]
             startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                          id result, NSError *error)
            {
                NSLog(@"Your get the result here contain userid, name, email and picture");
             }];
thor
  • 21,418
  • 31
  • 87
  • 173