我正在尝试从Facebook获取我的朋友个人资料图片和名称。我在facebook上创建了一个应用程序,并在.plist中添加了“FacebookAppID”,“FacebookDisplayName”和“URL Type”。但我无法提取信息。它是关于Facebook应用程序的权限?如果是的话,我怎样才能获得Facebook的权限。
这是我的代码部分;
- (IBAction)loginButtonTapped:(id)sender {
NSArray *permissionArray = [NSArray arrayWithObjects:@"user_about_me",nil];
[FBSession openActiveSessionWithReadPermissions:permissionArray allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState state,NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
}
- (void)sessionStateChanged:(FBSession *)session state:(FBSessionState) state error:(NSError *)error
{
FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
NSDictionary* result,
NSError *error) {
NSArray* friends = [result objectForKey:@"data"];
NSLog(@"Found: %i friends", friends.count);
NSLog(@"result: %@ friends", result);
for (NSDictionary<FBGraphUser>* friend in friends) {
NSLog(@"I have a friend named %@ with id %@", friend.name, friend.id);
}
}];
}
感谢您的回答和兴趣。
最诚挚的问候。