1

我正在使用 Facebook iOS SDK 并检索了用户好友列表。现在我有了每个朋友的姓名和身份证。

我想找回好友头像,可以吗?

谢谢!

4

3 回答 3

12

您可以使用此 URL 获取该图片

http://graph.facebook.com/IdOfTheUer/picture?type=normal

您也可以像这样使用他们的用户名:

例如

http://graph.facebook.com/facebook/picture?type=normal

http://graph.facebook.com/11239244970/picture?type=normal

于 2012-04-20T11:49:02.680 回答
10

在 cellForRowAtIndexPath 中,您已经获得了 facebook 用户的 id .....我说得对吗???之后,只需使用下面的 url 通过 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;
}
于 2012-04-20T15:32:13.867 回答
3
 -(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它会返回你朋友的所有信息。

于 2012-04-20T12:46:13.223 回答