Reputation: 201
I am comparing my results with the graph api explorer. I have a dummy account with 6 tagged pictures of mine. From iOs using FBGraph i get access token with permission "user_photos"
On calling me/photos I get back only one photo.
If i generate access token from graph api explorer with same "user_photos" permission, i get back all 6 photos.
Can anyone enlighten me why do I not get all the photos I am tagged in.
Regards
Upvotes: 1
Views: 785
Reputation: 1388
you're not getting the photos from the albums, you're getting only the non-albumed photos. get the albums list, with something like this,
- (NSMutableArray*)getAlbums{
NSLog(@"get pictures");
NSMutableArray* _albums = [[NSMutableArray alloc] init];
NSString* requestString = [NSString stringWithFormat:@"%@/%@/albums?access_token=%@",FACEBOOK_GRAPH_URL,[defaults valueForKey:@"facebook_id"],[defaults objectForKey:@"FBAccessTokenKey"]];
ASIHTTPRequest* request = [[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:requestString]];
[request startSynchronous];
SBJSON *parser = [[SBJSON alloc] init];
NSDictionary *dddd = (NSDictionary *) [parser objectWithString:[request responseString] error:nil];
NSDictionary *data = [dddd objectForKey:@"data"];
for(NSDictionary* k in data){
NSLog(@"album %@, count %@",[k valueForKey:@"id"],[k valueForKey:@"count"]);
if([k valueForKey:@"count"] && [[k valueForKey:@"count"] intValue] > 0)
[_albums addObject:[NSMutableDictionary dictionaryWithDictionary:k]];
}
for(NSMutableDictionary* album in _albums){
NSMutableArray* a = [self getPicturesForAlbum:[album valueForKey:@"id"]];
[album setValue:a forKey:@"photos"];
}
return _albums;
}
you'll get an NSArray of NSDictionaries, and in each a photos array as a dictionary just like you get them from facebook in the function you describe above.
- (NSMutableArray*)getPicturesForAlbum:(NSString*)albumNo{
NSLog(@"get pictures");
NSMutableArray* pics = [[NSMutableArray alloc] init];
NSString* requestString = [NSString stringWithFormat:@"%@/%@/photos?access_token=%@",FACEBOOK_GRAPH_URL,albumNo,[defaults objectForKey:@"FBAccessTokenKey"]];
ASIHTTPRequest* request = [[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:requestString]];
[request startSynchronous];
SBJSON *parser = [[SBJSON alloc] init];
NSDictionary *dddd = (NSDictionary *) [parser objectWithString:[request responseString] error:nil];
NSDictionary *data = [dddd objectForKey:@"data"];
for(NSDictionary* k in data){
for(id i in [k allKeys]){
if([i isEqualToString:@"source"]){
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
[dict setValue:[k valueForKey:i] forKey:@"photo"];
[dict setValue:[k valueForKey:@"created_time"] forKey:@"created_time"];
[dict setValue:[k valueForKey:@"picture"] forKey:@"thumb"];
if([k valueForKey:@"name"])
[dict setValue:[k valueForKey:@"name"] forKey:@"name"];
[pics addObject:dict];
}
}
}
return pics;
}
and then check for each album, which are the photos in it which you need. hope that helps.
Upvotes: 1