Uygulamamda ad, kimlik vb. Ile Facebook arkadaş listesini almaya çalışıyorum.iOS'ta Facebook Friend List'i Alın
- (IBAction)onFBLogin:(id)sender {
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login
logInWithReadPermissions: @[@"public_profile", @"email", @"user_friends"]
fromViewController:self
handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
NSLog(@"Process error");
} else if (result.isCancelled) {
NSLog(@"Cancelled");
} else {
NSLog(@"%@", result);
[self getFBEmailAddress];
}
}];
}
-(void)getFBEmailAddress{
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me"
parameters:@{@"fields": @"picture, email, friends"}]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSString *pictureURL = [NSString stringWithFormat:@"%@",[result objectForKey:@"picture"]];
mFBId = [NSString stringWithFormat:@"%@",[result objectForKey:@"id"]];
NSLog(@"My Profile : %@", result);
NSLog(@"email is %@", [result objectForKey:@"email"]);
[self getFBFriendList];
}
else{
NSLog(@"%@", [error localizedDescription]);
}
}];
}
-(void)getFBFriendList{
NSString* graphPat = [[NSString alloc] initWithFormat:@"%@/friends", mFBId];
FBSDKGraphRequest *requestFriends = [[FBSDKGraphRequest alloc]
initWithGraphPath:graphPat
parameters:@{@"fields": @"id, name"}
HTTPMethod:@"GET"];
[requestFriends startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
if (!error && result)
{
NSArray *allFriendsResultData = [result objectForKey:@"data"];
if ([allFriendsResultData count] > 0)
{
for (NSDictionary *friendObject in allFriendsResultData)
{
NSString *friendName = [friendObject objectForKey:@"name"];
NSString *friendID = [friendObject objectForKey:@"id"];
NSLog(@"%@ : %@", friendID, friendName);
}
}
}
}];}
Facebook ile giriş yapmayı ve profilimi almayı başarabiliyorum. Bundan sonra arkadaşların grafik api üzerinden arkadaş listesi almaya çalıştım. Ama o zaman, sadece aşağıdaki gibi takip eden arkadaşlar saydı.
friends = {
data = (
);
summary = {
"total_count" = 2;
};
};
id = 60XXXXXX1295X;
picture = {
data = {
"is_silhouette" = 0;
url = "https://scontent.xx.fbcdn.net/hprofile-xfa1/v/t1.0-1/p50x50/1..._501957533...";
};
};
Kimlik, ad vb. Gibi arkadaş listesiyle ilgili tüm bilgileri nasıl alabilirim? Daha önce uygulanan herhangi biri varsa lütfen bana yardımcı olun. Teşekkür ederim.