获取电子邮件地址通过使用Facebook的SDK 3.0.1为Android

编程入门 行业动态 更新时间:2024-10-10 23:15:59
本文介绍了获取电子邮件地址通过使用Facebook的SDK 3.0.1为Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我目前正在开发旨在通过使用Facebook的acoount验证任何用户的应用程序。

I'm currently developing an application which aims to authenticate any user by using Facebook acoount.

我在从用户帐户获取用户的电子邮件故障。我的code低于

I have a trouble in getting user email from user's account. My code is below

private void signInWithFacebook() { SessionTracker mSessionTracker = new SessionTracker(getBaseContext(), new StatusCallback() { public void call(Session session, SessionState state, Exception exception) { } }, null, false); String applicationId = Utility.getMetadataApplicationId(getBaseContext()); Session mCurrentSession = mSessionTracker.getSession(); if (mCurrentSession == null || mCurrentSession.getState().isClosed()) { mSessionTracker.setSession(null); Session session = new Session.Builder(getBaseContext()).setApplicationId(applicationId).build(); Session.setActiveSession(session); mCurrentSession = session; } if (!mCurrentSession.isOpened()) { Session.OpenRequest openRequest = null; openRequest = new Session.OpenRequest(FacebookLoginActivity.this); if (openRequest != null) { openRequest.setDefaultAudience(SessionDefaultAudience.FRIENDS); openRequest.setPermissions(Arrays.asList("user_birthday", "email", "user_location")); openRequest.setLoginBehavior(SessionLoginBehavior.SSO_WITH_FALLBACK); mCurrentSession.openForRead(openRequest); } }else { Request.executeMeRequestAsync(mCurrentSession, new Request.GraphUserCallback() { public void onCompleted(GraphUser user, Response response) { Log.w("myConsultant", user.getId() + " " + user.getName() + " " + user.getLink() + " "+ response); } }); } }

我使用Facebook的SDK 3.0.1为Android。 我已经设置了Facebook的图形API所需的权限。 在响应XML,有没有这样的领域,如电子邮件。 Facebook的SDK单证不够好,我不知道热,以获取电子邮件地址。

I am using Facebook SDK 3.0.1 for Android. I have set the permissions required by the Facebook Graph Api. In the response xml, there is no such field like email. Facebook Sdk documentations are not good enough and I don't know hot to obtain email address.

您及时答复将大大AP preciated。

Your prompt reply will be greatly appreciated.

在此先感谢,

推荐答案

电子邮件是不是所返回的默认字段。相反,你应该创建一个meRequest,并把它传递参数,如:。栏=电子邮件

Email is not a default field that's returned. Instead, you should create a meRequest, and pass it a parameter like: fields=email.

Request me = Request.newMeRequest(mCurrentSession, new GraphRequestCallback() {...}); Bundle params = me.getParameters(); params.putString("fields", "email,name"); me.setParameters(params); me.executeAsync();

更多推荐

获取电子邮件地址通过使用Facebook的SDK 3.0.1为Android

本文发布于:2023-11-28 14:23:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642776.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:电子邮件地址   Facebook   SDK   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!