gpt4 book ai didi

ios - 获取用户信息 Facebook SDK iOS

转载 作者:行者123 更新时间:2023-11-29 03:07:23 34 4
gpt4 key购买 nike

我遵循了一些在线指南,但我不知道如何获取 Facebook 等用户的用户名。登录和 session 工作正常。但我不能只取当前用户的值。这是工作代码

 if (!appDelegate.session.isOpen) {
// create a fresh session object
appDelegate.session = [[FBSession alloc] init];

// if we don't have a cached token, a call to open here would cause UX for login to
// occur; we don't want that to happen unless the user clicks the login button, and so
// we check here to make sure we have a token before calling open
if (appDelegate.session.state == FBSessionStateCreatedTokenLoaded) {
// even though we had a cached token, we need to login to make the session usable
[appDelegate.session openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {



NSLog(@"SESSION FACEBOOK OK");

// how i get username ?

提前致谢

最佳答案

了解如何使用 Facebook Graph API .

请求user info :

[FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
// Success! Include your code to handle the results here
NSLog(@"user info: %@", result);
} else {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
}
}];

关于ios - 获取用户信息 Facebook SDK iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22615022/

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