How to get facebook album photos in iPhone SDK?

I am developing an application for the iPhone that receives a facebook album with this URL https://graph.facebook.com/me/albums?access_token=2227470867|2.ZJr73vaEvFeN4fI_A70RFw__.3600.1297090800-100000566543036|WmgxdwULBgKXl8J7ksIA

Now I want to get photos from this album.

Any idea would be appreciated.

Thanks at Advance.

+8
ios facebook facebook-graph-api facebook-ios-sdk
source share
4 answers

So / me / albums returns an array of Album Objects , each of which has an id .

If the album had ID 99394368305, you can go to

https://graph.facebook.com/99394368305/photos

to get an array of photo objects .

Each of them will have picture and source properties to get image data from facebook.

All of them will have an images array if you want pre-scaled images, not just the originals.


All facebook requests return JSON - I assume you know how to parse this?

+13
source share

It takes a lot of time due to the following steps;

1) get the friend uid using:

 NSString *urlString=[NSString stringWithFormat:@"https://graph.facebook.com/me/friends?access_token=%@&fields=id,picture,name,birthday",fbGraph.accessToken]; 

2) set friends uid to get album id:

 NSString *urlString1=[NSString stringWithFormat:@"https://graph.facebook.com/%@/albums?access_token=%@",obj.uid,fbGraph.accessToken]; NSString *album = [[[_response1 objectForKey:@"data"]objectAtIndex:j]objectForKey:@"name"]; if ([album isEqualToString:@"Profile Pictures"]) { albumid = [[[_response1 objectForKey:@"data"]objectAtIndex:j]objectForKey:@"id"]; } 

3) then put the album ID to get a snapshot from this album:

 NSString *albumUrl=[NSString stringWithFormat:@"https://graph.facebook.com/%@/photos?type=album&access_token=%@",albumid,fbGraph.accessToken]; NSString *picUrl=[[[[[_response2 objectForKey:@"data"]objectAtIndex:0]objectForKey:@"images"]objectAtIndex:0]objectForKey:@"source"]; 

Tell me another way to get a large profile picture in one step to save time.

+3
source share

The code below should do the right thing for you. He receives albums for registered users, and then requests for photos of these albums. In the place where there is a comment, you will have access to all photos. For more information, you can refer to the docs :

 FBRequest *request = [FBRequest requestForGraphPath:@"me/albums"]; [request startWithCompletionHandler:^(FBRequestConnection *connection, NSDictionary <FBGraphUser> *my, NSError *error) { if ([my[@"data"]count]) { for (FBGraphObject *obj in my[@"data"]) { FBRequest *r = [FBRequest requestForGraphPath:[NSString stringWithFormat:@"/%@/photos", obj[@"id"]]]; [r startWithCompletionHandler:^(FBRequestConnection *c, NSDictionary <FBGraphUser> *m, NSError *err) { //here you will get pictures for each album }]; } } }]; 
+3
source share

New Facebook Developer:

 FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"/{user-id}" parameters:params HTTPMethod:@"GET"]; [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { // Handle the result }]; 

Latest Facebook Graphics API Documents

0
source share

All Articles