Facebook iOS SDKを使用していて、ユーザーの友達リストを取得しました。これで、それぞれの友達の名前とIDがわかりました。
友達のプロフィール写真を取得したいのですが、可能ですか?
ありがとう!
Facebook iOS SDKを使用していて、ユーザーの友達リストを取得しました。これで、それぞれの友達の名前とIDがわかりました。
友達のプロフィール写真を取得したいのですが、可能ですか?
ありがとう!
この URL を使用してその写真を取得できます
http://graph.facebook.com/IdOfTheUer/picture?type=normal
次のようにユーザー名を使用することもできます。
例えば
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;
}
-(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
と友達のすべての情報が返されます。