我正在尝试使用使用该解决方案和facebook sdk的应用程序从用户检索一堆Facebook信息,但我还没能成功完成。
首先,我检查用户是否已登录,以及他们是否显示具有facebook权限的解析视图控制器。
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
if (![PFUser currentUser] || ![PFFacebookUtils isLinkedWithUser:[PFUser currentUser]]) {
NSArray *permissionsArray = @[@"public_profile", @"user_birthday", @"user_photos", @"user_about_me", @"user_likes", @"user_relationship_details"];
LoginViewController *logInViewController = [[LoginViewController alloc] init];
[logInViewController setDelegate:self];
[logInViewController setFacebookPermissions:[NSArray arrayWithObjects:permissionsArray, nil]];
[logInViewController setFields:PFLogInFieldsFacebook | PFLogInFieldsDismissButton];
[self presentViewController:logInViewController animated:YES completion:NULL];
} else {
[self getUserInfo];
}
}
然后,一旦用户登录,我就会尝试获得以下权限。
-(void)getUserInfo {
FBSDKGraphRequest *requestMe = [[FBSDKGraphRequest alloc]initWithGraphPath:@"me" parameters:nil];
FBSDKGraphRequest *requestBirthday = [[FBSDKGraphRequest alloc]initWithGraphPath:@"me/user_birthday" parameters:nil];
FBSDKGraphRequest *requestPhotos = [[FBSDKGraphRequest alloc]initWithGraphPath:@"me/photos" parameters:nil];
FBSDKGraphRequest *requestAboutMe = [[FBSDKGraphRequest alloc]initWithGraphPath:@"me/about_me" parameters:nil];
FBSDKGraphRequest *requestLikes = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"/me/likes"
parameters:nil
HTTPMethod:@"GET"];
FBSDKGraphRequest *requestRelationship = [[FBSDKGraphRequest alloc]initWithGraphPath:@"me/relationship_details" parameters:nil];
FBSDKGraphRequestConnection *connection = [[FBSDKGraphRequestConnection alloc] init];
[connection addRequest:requestMe completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
userName = result[@"name"];
userGender = result[@"gender"];
userId = result[@"id"];
if (connection) {
[self setMe];
}
}];
[connection addRequest:requestBirthday completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
}];
[connection addRequest:requestPhotos completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
}];
[connection addRequest:requestAboutMe completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
}];
[connection addRequest:requestLikes completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
}];
[connection addRequest:requestRelationship completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
}];
[connection start];
}
requestMe
工作正常并且我检索用户信息,但是当我让NSLog输出任何其他权限的结果时,它总是null
而我不确定我做错了什么。在文档中,它表示如果开发人员想要检索有关他自己的信息,则该应用程序不必进行审核,因此问题不在于该应用尚未经过审核。
为什么我无法检索信息?是因为我要求提供错误的信息吗?任何帮助将不胜感激!
答案 0 :(得分:1)
如果您的应用尚未通过“登录审核”,则无法请求扩展权限。唯一的例外是,如果您在测试应用时使用管理员/测试人员/开发人员用户。
见