没有得到所有的照片用户被标记在Facebook [英] Not getting all the photos user is tagged in facebook

查看:116
本文介绍了没有得到所有的照片用户被标记在Facebook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将我的结果与图表API进行比较。我有一个虚拟账户,我的6张标签图片。
从使用FBGraph的iOs获取访问权限user_photos



在打电话给我/照片时,我只收到一张照片。



如果我从图形API资源管理器生成访问令牌,具有相同的user_photos权限,我可以收回所有6张照片。



任何人都可以启发我为什么没有收到我标记的所有照片。



p>

解决方案

您没有从相册获取照片,只能收到非专辑照片。
得到这样的相册列表,

   - (NSMutableArray *)getAlbums {
NSLog (@获得图片);
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 * _albums中的相册){
NSMutableArray * a = [self getPicturesForAlbum:[album valueForKey:@id]];
[album setValue:a forKey:@photos];
}
return _albums;

}



NSArray的NSDictionaries,并在每个照片数组作为一个字典,就像你从Facebook中获得他们在上面描述的功能。

   - (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;

}



然后检查每个专辑,这是您需要的照片。
希望有帮助。


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

解决方案

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.

这篇关于没有得到所有的照片用户被标记在Facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆