根据教程,我已将 facebook 登录集成到我的应用程序中,但我找不到任何关于如何检索用户电子邮件地址的好信息。电子邮件真的是我唯一需要的东西。我能够获得其他基本信息。我的活动扩展了 FaceBookActivity。当用户点击登录我的应用程序时,我调用:
this.openSession();
然后我有:
@Override
protected void onSessionStateChange(SessionState state, Exception exception)
{
// user has either logged in or not ...
if (state.isOpened())
{
// make request to the /me API
Request request = Request.newMeRequest(
this.getSession(),
new Request.GraphUserCallback()
{
// callback after Graph API response with user object
@Override
public void onCompleted(GraphUser user, Response response)
{
if (user != null)
{
TextView welcome = (TextView) findViewById(R.id.welcome);
welcome.setText("Hello " + user.getName() + "!");
Log.d("user fname",user.getFirstName());
Log.d("user lname",user.getLastName());
Log.d("user username",user.getUsername());
Log.d("user email",(String)user.getProperty("email"));
}
}
}
);
Request.executeBatchAsync(request);
}
}
GraphUser 不公开电子邮件。有任何想法吗?
我在我的 facebook 开发面板中设置了“电子邮件”权限。