我正在使用Facebook iOS SDK,我检索了用户好友列表。 现在我有每个朋友的名字和身份。
我想检索朋友个人资料图片,是否有可能?
谢谢!
答案 0 :(得分:12)
您可以使用此网址获取该图片
http://graph.facebook.com/IdOfTheUer/picture?type=normal
您也可以使用他们的用户名:
例如
答案 1 :(得分:10)
在cellForRowAtIndexPath中你已经获得了facebook用户的身份.....我是对的??? 之后只需使用bellow 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;
}
答案 2 :(得分: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
它将返回您朋友的所有信息。