1

Facebook iOS SDKを使用していて、ユーザーの友達リストを取得しました。これで、それぞれの友達の名前とIDがわかりました。

友達のプロフィール写真を取得したいのですが、可能ですか?

ありがとう!

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 に答える