【问题标题】:Facebook SDK loads default image and not image from my profile, why?Facebook SDK 从我的个人资料中加载默认图像而不是图像,为什么?
【发布时间】:2012-06-26 14:18:32
【问题描述】:

我在我的应用中设置了这些 facebook 权限:

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]

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

documentationuser_photos 声明:

提供对用户上传的照片的访问权限,以及 用户已被标记在

【问题讨论】:

    标签: ios facebook facebook-graph-api


    【解决方案1】:

    用户头像不需要user_photos 权限。图片可能来自 facebook 缓存,您应该使用以下 url 获取图片。

    http://graph.facebook.com/<facebook id>/picture
    

    【讨论】:

      猜你喜欢
      • 2022-10-16
      • 1970-01-01
      • 2015-03-17
      • 2016-02-03
      • 2011-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多