Raj
Raj

Reputation: 637

iOS FB graph api access album pictures in large scale

I am getting number of arrays by using the following graph query

"me?fields=albums.fields(id,name)"

After that I want to fetch photos related to each album for this I am using

NSString * graphPath = [NSString stringWithFormat:@"%@?fields=photos.fields(id,link,picture)", albumID]; 

By using this I am getting photos of each album. but in small size. I want this photos in large size

For this I have searched and I got this

[facebook requestWithGraphPath:@"me?fields=id,first_name,last_name,picture.type(large),gender,email" andDelegate:self];

But I think this is for all my pictures. I need to access photos by album id. Please help me to how to write query for fetching large size photos by album id.

I have tried this NSString * graphPath = [NSString stringWithFormat:@"%@?fields=photos.fields(id,link,picture.type(large))", albumID]; but no result.

Thanks in advance.

Upvotes: 0

Views: 959

Answers (2)

mak
mak

Reputation: 1183

       NSString *albumUrl=[NSString stringWithFormat:@"https://graph.facebook.com/%@/photos?type=album&access_token=%@",albumId,fbAccessToken];

       NSLog(@"path %@",albumUrl);
       NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:albumUrl]];
       NSURLResponse *response = nil;
       NSError *error= nil;
       NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
       NSString *responseString1 = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
       NSLog(@"data is: %@",[responseString1 JSONValue]);

You can see the output in the console, and you'll find images of differing height and size. You can pick the desired one.

The console displays the following for a sample photo in a sample album id:

 {
        "created_time" = "2013-08-08T06:58:29+0000";
        from =             {
            id = 100004738364054;
            name = "Rtpl Dev";
        };
        height = 183;
        icon = "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yz/r/StEh3RhPvjk.gif";
        id = 196228140545130;
        images =             (
                            {
                height = 183;
                source = "https://fbcdn-sphotos-a-a.akamaihd.net/hphotos-ak-frc3/1157748_196228140545130_1027750180_n.jpg";
                width = 275;
            },
                            {
                height = 183;
                source = "https://fbcdn-sphotos-a-a.akamaihd.net/hphotos-ak-frc3/q71/1157748_196228140545130_1027750180_n.jpg";
                width = 275;
            },
                            {
                height = 119;
                source = "https://fbcdn-photos-a-a.akamaihd.net/hphotos-ak-frc3/1157748_196228140545130_1027750180_a.jpg";
                width = 180;
            },
                            {
                height = 86;
                source = "https://fbcdn-photos-a-a.akamaihd.net/hphotos-ak-frc3/1157748_196228140545130_1027750180_s.jpg";
                width = 130;
            },
                            {
                height = 86;
                source = "https://fbcdn-photos-a-a.akamaihd.net/hphotos-ak-frc3/s75x225/1157748_196228140545130_1027750180_s.jpg";
                width = 130;
            }
        );

Upvotes: 1

Raj
Raj

Reputation: 637

Finally I got the answer , It took my 6 hours :( Check the following query. NSString * graphPath = [NSString stringWithFormat:@"%@?fields=photos.fields(id,link,source)", albumID];

Only we need to replace source in place of picture . So it will return the original image with original size.

Upvotes: 5

Related Questions