iOS facebook sdk how to download album, profile photos data

前端 未结 2 1450
一向
一向 2021-01-03 02:59

I would like to allow my iPhone App users to view and select from their facebook profile photos, download the photo to use as a profile pic. I am currently using the Facebo

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-03 03:21

    For the sake of future viewers, I'm putting the answer to my own question since I haven't received a complete answer from anyone else.

    First, you must have the right permissions, either "user_photos" or "friends_photos". Then you have to make sure that your test device updates your permissions -- I think restarting the device is what ultimately did it for me.

    Once you've done that, you can get the JSON list of albums, after logging in via SSO, using this call:

    [facebook requestWithGraphPath:@"me/albums" andDelegate:self];
    

    This will give JSON array (under key data) with all kinds of information about each album, including the ID. To get a list of photos for a particular album ID (say its '123456789') do the following:

    NSString * albumId = @"123456789";
    NSString * path = [NSString stringWithFormat:@"%@/photos", albumId];
    [facebook requestWithGraphPath:path andDelegate:self];
    

    Your response will of course come via the FBRequestDelegate method request:didLoad where you can process the JSON data.

提交回复
热议问题