簡體   English   中英

iOS Facebook SDK-檢索朋友個人資料圖片

[英]iOS Facebook SDK - Retrieve Friends Profile Pictures

我正在使用Facebook iOS SDK,並檢索了用戶朋友列表。 現在我有了每個朋友的名字和編號。

我想檢索朋友的個人資料圖片,可以嗎?

謝謝!

在cellForRowAtIndexPath中,您已經獲得了Facebook用戶的ID。 之后,只需使用以下網址即可通過URLRequest獲取個人資料圖片。...

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if([friends count]!=0)
    {                        
        NSString *strurl = [[NSString alloc] initWithFormat:@"https://graph.facebook.com/%@/picture",[[friends objectAtIndex:indexPath.row] objectForKey:@"id"]];
        NSURL *url=[NSURL URLWithString:strurl];///here you can retrive the image
        [cell setObjItem:url title:[[friends objectAtIndex:indexPath.row] objectForKey:@"name"]];
        // Configure the cell.
    }
    else
    {
        NSLog(@"<<<<<<<<<<------Array Null-------->>>>>>>");
    }
    return cell;
}
 -(void)fbFriends {
        [self.facebook requestWithGraphPath:@"me/friends" andDelegate:self];
    }
    -(void)fbFriendsInfo :(NSString *)profileid {
        [self.facebook requestWithGraphPath:profileid andDelegate:self];
    }


    - (void)request:(FBRequest *)request didLoad:(id)result{
        [self hideSpinner];

        lblGender.text = [result objectForKey:@"gender"];
        lblName.text = [result objectForKey:@"name"];
        self.idi = [result objectForKey:@"id"];

        NSString *first_name = [result objectForKey:@"first_name"];
        NSString *gender = [result objectForKey:@"gender"];
        NSString *last_name = [result objectForKey:@"last_name"];
        NSString *link = [result objectForKey:@"link"];
        NSString *name = [result objectForKey:@"name"];
        NSString *updated_time = [result objectForKey:@"updated_time"];

        NSLog(@"Profile Info : \n\n%@,\n%@,\n%@,\n%@,\n%@,\n%@,\n%@",first_name,gender,idi,last_name,link,name,updated_time);

        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:AlertName message:@"Facebook Done." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
        [alert release];
    }

使用共享控制器類並調用fbFriends這樣您將獲得朋友ID,然后調用fbFriendsInfo ,它將返回您朋友的所有信息。

暫無
暫無

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

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