8

I am developing a iPhone application which get facebook album with this URL https://graph.facebook.com/me/albums?access_token=2227470867|2.ZJr73vaEvFeN4fI_A70RFw__.3600.1297090800-100000566543036|WmgxdwULBgKXl8J7ksGIA1tyGik

Now i want to get photos from this album.

Any Idea will be appreciated.

Thanks in Advance.

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Apekshit
  • 767
  • 2
  • 13
  • 27

4 Answers4

13

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

If an album had an id of 99394368305, you can go to

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

to get an array of photo objects.

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

They will all have an images array as well if you want pre-scaled images instead of just the originals.


All the facebook queries give JSON back - I'm assuming that you know how to parse this?

deanWombourne
  • 38,189
  • 13
  • 98
  • 110
  • Can you please give answer for this question ? http://stackoverflow.com/questions/4957260/how-to-comment-or-like-a-photo-in-facebook-through-fbconnect-or-graph-api-in-ipho – Apekshit Feb 10 '11 at 12:56
  • @deanWombourne https://graph.facebook.com/album_id/photos returns "False" when I execute it on my browser. How do you use it with FBConnect of Facebook iOS sdk? – Jimit Jul 08 '11 at 02:35
  • What are you putting as your `album_id` and do you have permissions to view that album? (I'm assuming you're not just putting album_id straight in there!) – deanWombourne Jul 09 '11 at 18:52
  • but in my case it is returning a blank json file am doing the same procedure as you suggested – varun bhardwaj May 03 '12 at 06:23
  • @varunbhardwaj Ask a question yourself instead of commenting on someone else's question :) And when you ask the question, don't forget to put in the code you're using and the json you get back as a response. – deanWombourne May 03 '12 at 10:44
  • http://stackoverflow.com/questions/30207465/ios-facebook-album-photos-picker/31789234#31789234 – Maulik shah Aug 07 '15 at 01:02
3

It takes lot of time because of following steps;

1) get uid of friend using :

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

2) put 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 the picture from that 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"];

Kindly tell me some other method to get profile picture with large size in a single step to save time.

Shaik Riyaz
  • 11,204
  • 7
  • 53
  • 70
  • but i dont under stand that .. this all 3 method where i put.? i am newbie in ios. so plz guide me proper . – Raju Oct 31 '13 at 13:10
3

The code below should do the right job for you. It gets albums for logged user and then requests for photos of this albums. In the place where is a comment you will have the access to all photos. For more info you can refer to 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
            }];
        }
    }

}];
Julian
  • 9,299
  • 5
  • 48
  • 65
  • This is outdated/deprecated by Facebook developers, if you click on docs link. Hence I am adding new code by them below. – karan Feb 05 '16 at 11:14
0

Facebook developers new code:

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

Latest Facebook Graph API docs

karan
  • 3,319
  • 1
  • 35
  • 44