gpt4 book ai didi

ios - 在 ios 应用程序中获取某人的 facebook 公开个人资料

转载 作者:可可西里 更新时间:2023-11-01 06:20:04 24 4
gpt4 key购买 nike

我正在开发一个需要 Facebook 登录的 ios 应用程序。我已经成功地实现了登录过程。但是现在我无法找到如何以及在哪里可以获取用户的个人资料信息,如名字、姓氏、个人资料图片等...我的应用程序有权访问名字、姓氏、个人资料图片和电子邮件。

最佳答案

下面是使用最新的 Facebook SDK v4.0.1 获取个人 public_profile 的代码。您需要使用 FBSDKProfile 来获取个人资料。

-(void)viewDidLoad{
FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
[self.view addSubview:loginButton];

self.loginButton.readPermissions = @[@"public_profile", @"email", @"user_friends"];
self.loginButton.delegate = self;
[FBSDKProfile enableUpdatesOnAccessTokenChange:YES];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(profileUpdated:) name:FBSDKProfileDidChangeNotification object:nil];

}

-(void)profileUpdated:(NSNotification *) notification{
NSLog(@"User name: %@",[FBSDKProfile currentProfile].name);
NSLog(@"User ID: %@",[FBSDKProfile currentProfile].userID);
}

- (void) loginButton:(FBSDKLoginButton *)loginButton
didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result
error:(NSError *)error{

}

- (void)loginButtonDidLogOut:(FBSDKLoginButton *)loginButton{

}

关于ios - 在 ios 应用程序中获取某人的 facebook 公开个人资料,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29466795/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com