facebook SDK没有在android中发送电子邮件参数

时间:2015-02-13 14:52:53

标签: android facebook facebook-android-sdk

我从Facebook获取电子邮件时遇到问题。记录后,我发送所有数据,如姓名,姓氏等,但我想念他们需要的电子邮件。

GraphObject{graphObjectClass=GraphUser, state={"id":"1069060169776842","first_name":"Peter","timezone":1,"verified":true,"name":"Peter Javorek","locale":"sk_SK","link":"https:\/\/www.facebook.com\/app_scoped_user_id\/1069060169776842\/","last_name":"Javorek","gender":"male","updated_time":"2014-12-18T12:28:15+0000"}}

在Facebook开发者身上,我创建了一个新项目,我加入了Key Hashes,然后我将App ID作为教程添加到应用程序中。 我启用了公共应用程序,并包含LOGIN PERMISSIONS:
- 电子邮件
- public_profile
- user_friends

我使用过 - Facebook SDK 3.23.0

这是我的代码:

     private UiLifecycleHelper uiHelperFB;

     private Session.StatusCallback callback = new Session.StatusCallback() {
        @Override
        public void call(Session session, SessionState state, Exception exception) {
            onSessionStateChange(session, state, exception);
        }
     };

     private void onSessionStateChange(Session session, SessionState state, Exception exception) {
            if (state.isOpened()) {
                Log.v("motozo", "SessionOpen: ***");

                for (String sessionData : session.getPermissions()) {
                    Log.v("", "PERMISSIONS: " + sessionData);
                }

                GraphUserCallback graphUserCallback = new GraphUserCallback() {
                    @Override
                    public void onCompleted(GraphUser user, Response response) {
                        Log.v("", "Return: " + String.valueOf(user));
                    }
                };
                Request request = Request.newMeRequest(session, graphUserCallback);
                request.executeAsync();
            } else if (state.isClosed()) {
                Log.v("", "Logged out...");
            }
        }

    @Override
        public void onSaveInstanceState(Bundle outState) {
            super.onSaveInstanceState(outState);
            uiHelperFB.onSaveInstanceState(outState);
        }

    @Override
        protected void onCreate(Bundle savedInstanceState) {
            setContentView(R.layout.activity_first_page);
            super.onCreate(savedInstanceState);

            uiHelperFB = new UiLifecycleHelper(this, callback);
            uiHelperFB.onCreate(savedInstanceState);

            LoginButton fbLoginButton = (LoginButton) findViewById(R.id.fb_login_button);
            fbLoginButton.setPublishPermissions(Arrays.asList("email"));
        }

    @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            super.onActivityResult(requestCode, resultCode, data);
            uiHelperFB.onActivityResult(requestCode, resultCode, data);
        }

    @Override
        protected void onStop() {
            super.onStop();
            uiHelperFB.onStop();
        }

    @Override
        protected void onResume() {
            super.onResume();
            uiHelperFB.onResume();
        }

    @Override
        protected void onPause() {
            super.onPause();
            uiHelperFB.onPause();
        }

    @Override
        public void onDestroy() {
            super.onDestroy();
            uiHelperFB.onDestroy();
        }

这些是列表:

    02-13 15:19:58.878  14054-14054/facebookLog V/﹕ SessionOpen: ***
    02-13 15:19:58.878  14054-14054/facebookLog V/﹕ PERMISSIONS: email
    02-13 15:19:58.878  14054-14054/facebookLog V/﹕ PERMISSIONS: publish_actions
    02-13 15:19:58.878  14054-14054/facebookLog V/﹕ PERMISSIONS: basic_info
    02-13 15:19:59.154  14054-14054/facebookLog V/﹕ Return: GraphObject{graphObjectClass=GraphUser, state={"id":"1069060169776842","first_name":"Peter","timezone":7,"verified":true,"name":"Peter Javorek","locale":"sk_SK","link":"https:\/\/www.facebook.com\/app_scoped_user_id\/1069060169776842\/","last_name":"Javorek","gender":"male","updated_time":"2014-12-18T12:28:15+0000"}}

感谢您的帮助。

修改

在与其他FB帐户进行进一步测试后,我们注意到FB确实在我的请求中发送了电子邮件,但它仅针对某些帐户发送,对于其他帐户,即使他们的个人资料中有电子邮件也不会发送电子邮件。是否有一些影响这个的设置?无论如何要处理这个问题,以便我们收到那些通常不会发送给我们的帐户的电子邮件?

1 个答案:

答案 0 :(得分:0)

您必须为电子邮件执行特殊的图表调用,它不在默认响应中,请参阅此处的代码段:

https://stackoverflow.com/a/28439577/1134723