简体   繁体   English

获取信息的用户Facebook SDK iOS

[英]Get info user Facebook SDK iOS

I followed a little 'guides online, but I can not figure out how to get the username of the user such as Facebook. 我在网上遵循了一些“指南”,但是我不知道如何获取用户(如Facebook)的用户名。 The login and session work properly. 登录和会话正常工作。 But I can not just take the values ​​of the current user. 但是我不能仅仅采用当前用户的值。 This is the working code 这是工作代码

 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 ?

Thanks in advance 提前致谢

Learn how to use the Facebook Graph API . 了解如何使用Facebook Graph API

To request the 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   
   }
}];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM