我的Facebook登录解析工作完全没有问题,但生成的访问令牌没有显示好友列表的权限,虽然我在登录时给予该权限。当我使用Facebook Graph API'Friendlists'(fbID/friendlists)并且响应数组为空时,我开始知道。因此,也使用生成的相同访问令牌运行Graph API Explorer。它不告诉我任何错误和数据阵列是相同的空白,并与解析'pfloginviewcontroller'某些Facebook权限不能在ios中工作
调试信息“领域‘好友列表’仅在用户对象上的用户授予“read_custom_friendlists的许可后,访问”
这是我使用的方法
WLLoginViewController *login = [[WLLoginViewController alloc]init];
login.fields = PFLogInFieldsFacebook;
NSArray *permission = [[NSArray alloc]initWithObjects:@"email",@"read_custom_friendlists",@"publish_actions",@"user_location",@"user_hometown",@"user_website",@"user_about_me",@"user_photos",@"user_friends",@"read_custom_friendlists", nil];
login.facebookPermissions = permission;
WLLoginViewController继承PFUserLoginManager,我从其他类调用它。
- (void)logInViewController:(PFLogInViewController *)logInController didLogInUser:(PFUser *)user {
[FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
NSLog(@"permissions%@",logInController.facebookPermissions);
if(result) {
if ([result valueForKey:@"hometown"]) {
NSString *nn = [[result valueForKey:@"hometown"] valueForKey:@"name"];
[user setValue:[[result valueForKey:@"hometown"] valueForKey:@"name"] forKey:@"hometown"];
}
if ([result valueForKey:@"location"]) {
[user setValue:[[result valueForKey:@"location"] valueForKey:@"name"] forKey:@"location"];
}
[user setObject:[result valueForKey:@"id"] forKey:kWLUser_FacebookId];
[user setObject:[result valueForKey:@"name"] forKey:kWLUser_Name];
[user saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if([PFInstallation currentInstallation]) {
// save in background current installation.
[[PFInstallation currentInstallation] setObject:user forKey:@"user"];
[[PFInstallation currentInstallation]saveInBackground];
}
}];
[[ParseManager sharedInstance]saveDeviceToken:[[NSUserDefaults standardUserDefaults]objectForKey:@"DeviceToken"]];
[self dismissViewControllerAnimated:YES completion:nil];
}else {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Could not login" message:@"Could not login to facebook, please try again" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil];
[alert show];
}
}];
} 这是这是其当在代码的用户返回到应用程序从facebook.The的NSLog是示出了许可完美其中我给运行方法。
最后,这是用于处理Facebook的要求 方法 - (无效){handleFacebookFriendsRequest
NSString *queryParams = @"id,name,picture.width(350).height(250),location,hometown,likes.limit(100000),statuses.limit(1),languages";
[queryParams stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"%@",[FBSession activeSession].permissions);
NSLog(@"%@",[[FBSession activeSession].permissions description]);
NSLog(@"%@",[FBSession activeSession].accessTokenData.accessToken);
[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"me/friends?fields=%@",queryParams] completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
//change For getting everything out
NSLog(@"%@",[result objectForKey:@"data"]);
[[ApplicationDataModel sharedInstance]setFacebookFriendsList:[result objectForKey:@"data"]];
[self facebookRequestDidLoad:result];
} else {
[self facebookRequestDidFailWithError:error];
}
}];
}
我被困急需帮助。
否我必须将该朋友列表显示给用户,以便他可以向他们发送邀请加入我们的应用程序。 –
我必须为此请求read_custom_friendlists吗?我添加了'user_friends',它只是将我的应用程序管理员的好友列表带给我..这里应该是什么问题? –