在iOS应用程序中获取某个人的Facebook公开个人资料 [英] Getting facebook public profile of a person in ios app

查看:100
本文介绍了在iOS应用程序中获取某个人的Facebook公开个人资料的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am working on an ios app which requires Facebook Login.I have successfully implemented the login process.But now I am not able to find that how and where can i get the user's profile information like first name,last name, Profile Pic etc...My app has permissions to access firstName,lastName,Profile pic and Email.

推荐答案

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

Below is the code for getting person public_profile using latest Facebook SDK v4.0.1. You need to use FBSDKProfile to get person profile.

-(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应用程序中获取某个人的Facebook公开个人资料的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆