FQL 获取 facebook 好友信息列表和他们的照片
NSString *query = @"SELECT uid,name,first_name,last_name,pic_square FROM user WHERE uid IN (";
query = [query stringByAppendingFormat:@"SELECT uid2 FROM friend WHERE uid1 = %@)",userid];
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
query, @"query",
nil];
[_facebook requestWithMethodName: @"fql.query"
andParams: params
andHttpMethod: @"POST"
andDelegate:self];
您将通过以下方法得到响应
-(void)request:(FBRequest *)request didLoad:(id)result
举例
{
"first_name" =User;
"last_name" = R;
name = "User R";
"pic_square" = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash2/.jpg";
uid = 595sd1;
}
{},{} etc
希望这会有所帮助!
另一种方法是
获取用户的id(或昵称),从https://graph.facebook.com/idOrNick/picture获取图片
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture", id]];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *image = [UIImage imageWithData:data];
UIImageView *imgView = [[UIImageView alloc]init];
imgView.image = image;
对于尺寸
图片尺寸:
正方形 (50×50)
小(50 像素宽,可变高度)
大(大约 200 像素宽,可变高度)
并且要应用这种类型的大小,您必须将其附加到 URL 的末尾
例如
http://graph.facebook.com/"id or Nick"/picture?type=large。 [小/方形/大]