Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

how to increase change instagram api request from images default of 20 to 200

hello how to increase change instagram api request from images default of 20 to 200

4 Answers

Andrew Elliott
Andrew Elliott
6,003 Points

Hi,

Looking at the API documentation, you should be able to specify a count variable:

http://instagram.com/developer/endpoints/users/

eg https://api.instagram.com/v1/users/3/media/recent/?access_token=ACCESS-TOKEN&COUNT=200

Untested, but in theory should work.

thanks but its not work , is there a way of get more photo to download rather than the min 20,

here is the code

NSString *urlString = [[NSString alloc] initWithFormat:@"https://api.instagram.com/v1/tags/2014/recent/?access_token=ACCESS-TOKEN&COUNT=200=%@", self.accessToken];

NSURL *url = [[NSURL alloc] initWithString:urlString];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
NSURLSessionDownloadTask *task = [session downloadTaskWithRequest:request completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) {

    NSData *data = [[NSData alloc] initWithContentsOfURL:location];
    NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];

    self.photos = [responseDictionary valueForKeyPath:@"data"];

    dispatch_async(dispatch_get_main_queue(), ^{
        [self.collectionView reloadData];
        self.loading = NO;
    });
}];
[task resume];

}

Andrew Elliott
Andrew Elliott
6,003 Points

Hi Xlang,

Try changing:

NSString *urlString = [[NSString alloc] initWithFormat:@"https://api.instagram.com/v1/tags/2014/recent/?access_token=ACCESS-TOKEN&COUNT=200=%@", self.accessToken];

to

NSString *urlString = [[NSString alloc] initWithFormat:@"https://api.instagram.com/v1/tags/2014/recent/?access_token=%@&COUNT=200", self.accessToken];

THANKS , unfortunately its not work , i tried a following code which increase to the count to 33 from 20 however would like to get more, any suggestions?

NSString *urlString = [[NSString alloc]initWithFormat:@"https://api.instagram.com/v1/tags/2014/media/recent?access_token=%@&count=500", self.accessToken];