2012-06-26 30 views
1

我有我的应用程序设置这些Facebook的权限:Facebook SDK加载默认图像,而不是从我的个人资料图像,为什么?

NSArray *permissions = [[NSArray alloc] initWithObjects: 
            @"user_games_activity", 
            @"friends_games_activity", 
            @"publish_actions", 
            @"user_photos", 
            nil]; 
      [[myDelegate facebook] authorize:permissions]; 

我做的请求,像这样:

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"name,picture",@"fields",nil]; 
    [[delegate facebook] requestWithGraphPath:@"me" andParams:params andDelegate:self]; 

和处理类似的回应:

else if([request.url rangeOfString:@"me"].location != NSNotFound) 
    { 
     NSString *username = [result objectForKey:@"name"]; 
     NSLog(@"We think the username is %@", username); 
     helloGreeting.text = [NSString stringWithFormat:@"Hello %@", username]; 


     NSString *pictureUrl = [result objectForKey:@"picture"]; 
     NSLog(@"Now loading image [%@]", pictureUrl); 
     NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:pictureUrl]]; 
     profilePhoto.image = [UIImage imageWithData:data]; 
    } 

我得到的日志输出是:

2012-06-26 15:10:49.002 FacebookIntegrator[10549:f803] We think the username is James Elsey 
2012-06-26 15:10:49.003 FacebookIntegrator[10549:f803] Now loading image [http://profile.ak.fbcdn.net/static-ak/rsrc.php/v2/yo/r/UlIqmHJn-SK.gif] 

enter image description here

问题:为什么它获得默认通用的Facebook图标,而不是我自己的个人资料图片?使用上Graph Explorer相同的访问令牌,我可以得到我的个人资料图片图像URL

documentationuser_photos状态:

提供对用户上传的照片,照片 用户已

回答

1

用户头像不需要user_photos权限。图片可能来自Facebook缓存,你应该使用下面的网址为图片。

http://graph.facebook.com/<facebook id>/picture 
相关问题