facebookfacebook-graph-apiios8.3

iOS 8.3 Facebook SDK 4.1 Retrieve user's Profile Photo Album


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.


Solution

  • 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.