簡體   English   中英

如何訪問朋友的Facebook個人資料圖片?

[英]how can I access friends' facebook profile picture?

我需要訪問朋友的個人資料圖片,以將其顯示在游戲排行榜中。 我在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;
            }
            }
        }

     }];
 }

排行榜實例

    struct LeaderboardboardInstance
{
    __unsafe_unretained UILabel *pFriendName;
    __unsafe_unretained UILabel *pFriendScore;
    __unsafe_unretained UIImage *profilePicture;
};

也,

struct LeaderboardboardInstance m_pLeaderboardEntries[m_kuLeaderboardSize];

將此添加到您的字段列表

picture.type(large)

在結果對象中,您應該有一個名為picture的字典,其中包含圖像信息,包括用戶圖像的url

假設您已經登錄了一個Facebook用戶,並且擁有該朋友的Facebook ID,則可以采用以下方法:

NSString *imageUrl = [NSString stringWithFormat:@"http://graph.facebook.com/%@/picture?type=large", friendID];

然后,您可以使用NSURLConection或所需的任何下載圖像。

暫無
暫無

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

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