简体   繁体   English

Android Facebook Graph API JSON不返回电子邮件

[英]Android Facebook Graph API JSON returns no email

I'm currently having some issues trying to obtain the user's email via GraphUser api object. 我目前在尝试通过GraphUser api对象获取用户的电子邮件时遇到一些问题。

I managed to obtain firstname, lastname and everything else but not the email . 我设法获得了名字,姓氏和其他所有信息,但没有获得电子邮件

I've done my research that you'll need to add some permission to obtain user's email (login email to facebook, not xxx@facebook.com). 我已经完成了研究,您需要添加一些权限才能获取用户的电子邮件(将电子邮件登录到Facebook,而不是xxx@facebook.com)。 I'm stuck! 我被卡住了! How do I do this in Android? 如何在Android中执行此操作?

private class FacebookloginDelegateImpl extends FacebookloginDelegate
{
    /*
     * Optional callback method
     */ 
    protected void onCompletedProgress(GraphUser user,
            Response response) 
    {
        Log.d("FB UserID:", user.getId());
        Log.d("FB FirstName:", user.getFirstName());
        Log.d("FB LastName:", user.getLastName());
        Log.d("Object:", user.toString());
        Log.d("Response:", response.toString());
        //Log.d("FB Email:", (String) user.asMap().get("email"));

        String userID = user.getId();
        String firstname = user.getFirstName();
        String lastname = user.getLastName();
        String email= "";
        try {
            email = user.getInnerJSONObject().getString("email");
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        Log.d("FB Email:", email);

        LoginActivity.this.requestFacebookLogin(userID, firstname, lastname);

        //String stringData = "{\"ID\":\""+user.getId()+"\",\"Name\":\""+user.getName()+"\"}";  
    }

Are you sure that the user has set up another email than the default facebook one? 您确定用户设置了另一封电子邮件,而不是默认的Facebook电子邮件吗? Facebook forces everyone to have their email and you need to go in and change it in order to have another one. Facebook强迫每个人都拥有自己的电子邮件,您需要进入并更改它才能拥有另一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM