簡體   English   中英

Facebook SDK會加載默認圖像,而不是我個人資料中的圖像,為什么?

[英]Facebook SDK loads default image and not image from my profile, why?

我在應用程序中設置了以下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中使用相同的訪問令牌,我可以進入個人資料圖片網址

user_photos文檔指出:

提供對用戶上傳的照片以及為其添加了標簽的照片的訪問權限

用戶個人資料圖片不需要user_photos權限。 圖片可能來自facebook緩存,您應該使用以下URL作為圖片。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM