我需要访问朋友的个人资料图片才能在我的游戏排行榜中显示这些图片。我在stackoverflow上找到的帖子的大多数链接都不存在了。如何以类似于我在下面的代码中访问分数和名称的方式访问个人资料图片。
-(void)getLeaderboardInfo
{
[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"%llu/scores?fields=score,user", kuFBAppID] parameters:nil HTTPMethod:@"GET" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (result && !error)
{
int index = 0;
for (NSDictionary *dict in [result objectForKey:@"data"])
{
NSString *name = [[[[dict objectForKey:@"user"] objectForKey:@"name"] componentsSeparatedByString:@" "] objectAtIndex:0];
NSString *strScore = [dict objectForKey:@"score"];
// how do I get the objectforkey representing the image?
m_pLeaderboardEntries[index].pFriendName.text = [NSString stringWithFormat:@"%d. %@", index+1, name];
m_pLeaderboardEntries[index].pFriendScore.text = [NSString stringWithFormat:@"Score: %@", strScore];
// how do I add the image to my leaderboard entries?
index++;
if (index>5) {
break;
}
}
}
}];
}
LeaderboardInstance
struct LeaderboardboardInstance
{
__unsafe_unretained UILabel *pFriendName;
__unsafe_unretained UILabel *pFriendScore;
__unsafe_unretained UIImage *profilePicture;
};
此外,
struct LeaderboardboardInstance m_pLeaderboardEntries[m_kuLeaderboardSize];
答案 0 :(得分:1)
将其添加到字段列表
picture.type(large)
在结果对象中,您应该有一个名为picture
的词典,其中包含图像信息,包括用户图像的url
答案 1 :(得分:0)
假设您有一位Facebook用户登录并且有朋友的Facebook ID,那就可以了:
NSString *imageUrl = [NSString stringWithFormat:@"http://graph.facebook.com/%@/picture?type=large", friendID];
然后,您可以使用NSURLConection
或任何library下载图像。