ios - 获取用户信息 Facebook SDK iOS

标签 ios objective-c facebook facebook-graph-api facebook-ios-sdk

我遵循了一些在线指南,但我不知道如何获取 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/

相关文章:

ios - 有没有办法在编辑时只激活搜索栏上的取消按钮?

iphone - 如何修复 iPhone 应用程序中的多个音频流造成的失真?

Objective-C 释放单例

ios - FBSDKShareKit : Share Form does not prompt

ios - MKMapSnapshotter 结果的边界框坐标

ios - 如何在容器 View 中的 tableview 周围获取可见框架

iphone - 使用标签栏和导航 Controller , View 被解除到错误的 View

ios - 当用户触摸 UIBarButtonItem 时,在 tableView 上显示 UISearchBar

facebook - 即使使用 Facebook Connect 登录,也强制用户输入登录信息

android - 使用 UiLifecycleHelper 实现 Facebook 登录