获取来自Facebook的Android SDK用户的电子邮件 [英] Get user email from Facebook SDK android
问题描述
我刚开始接触Facebook的SDK,我现在有一个具有自己的登录系统的应用程序,用户输入自己的电子邮件和密码,然后应用程序检查MySQL数据库中找到用户。
如果用户是他们返回的用户信息,并将其记录到应用程序。
I am just starting out with the Facebook SDK, I currently have an app that has its own login system, the user enters their email and password and then the app checks a mysql database to find the user. If the user is their it returns the user info and logs them into the app.
我所试图做的是让用户只需preSS Facebook的按钮,并已经Facebook的SDK返回用户的电子邮件链接到他们的Facebook账户。
然后,我可以搜索我的数据库为电子邮件和登录用户或为他们创建一个帐户,如果他们是与电子邮件没有考虑。
What I am trying to do is allow the user to just press a Facebook button and have the Facebook SDK return the users email linked to their Facebook account. Then I can search my database for that email and log the user in or create an account for them if their is no account with that email.
我把一切都从具有Facebook的SDK实际返回的电子邮件为用户设置了分开。我不知道从哪里开始的这一点,真的可以使用一些帮助!
I have everything set up apart from having the Facebook SDK actually return the email for the user. I am not sure where to start with this and could really use some help!
推荐答案
您有两个选择来获取Facebook的用户的电子邮件:
You have two options to get the email of the Facebook user:
- 实施 的Facebook登录 与
电子邮件
许可 - 通过获取用户数据
Request.newMeRequest()
。这是在这里解释的:<一href=\"https://developers.facebook.com/docs/android/scrumptious/personalize/\">Personalize
- Implement Facebook Login with
email
permission - Get the user data by using
Request.newMeRequest()
. This is explained here: Personalize
库:<一href=\"https://github.com/sromku/android-simple-facebook\">https://github.com/sromku/android-simple-facebook
- 设置
电子邮件
使用权限Permissions.EMAIL
-
然后,登录
- Set
email
permission by usingPermissions.EMAIL
Then, login
mSimpleFacebook.login(MainActivity.this);
然后,获得与邮件配置文件
mSimpleFacebook.getProfile(new OnProfileRequestAdapter()
{
@Override
public void onComplete(Profile profile)
{
String id = profile.getId();
String firstName = profile.getFirstName();
String email = profile.getEmail();
// ... and many more properties of profile ...
}
});
这篇关于获取来自Facebook的Android SDK用户的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!