1

私はAndroidアプリケーションでFacebookのサインインに次のコードを使用しました。許可画面にログインした後、電子メールの許可を求めず、onSessionStateChangeメソッドで電子メールを受信しません。コードに問題はありますか。前進..

OpenRequest openRequest = new OpenRequest(this); リストreadPermissions=new ArrayList(); readPermissions.add( "email"); openRequest.setPermissions(readPermissions); openRequest .setLoginBehavior(SessionLoginBehavior.SSO_WITH_FALLBACK); mCurrentSession.openForRead(openRequest);

private void onSessionStateChange(Session session, SessionState state,
            Exception exception) {

        Log.e("OnsessionStateChange", "------");
        // Only make changes if the activity is visible
        // Get the number of entries in the back stack
        if (state.isOpened()) {
            Log.e("OnsessionStateChange", "--State opened----");

            Request.executeMeRequestAsync(session,
                    new Request.GraphUserCallback() {

                        public void onCompleted(GraphUser user,
                                Response response) {
                            Session session = Session.getActiveSession();
                            Log.w("myConsultant",
                                    user.getId() + " " + user.getFirstName()
                                            + " " + user.getFirstName() + " "
                                            + user.getInnerJSONObject());
                            Log.d("user email",
                                    (String) user.getProperty("email") + "link"
                                            + user.getLink());


                        }
                    });
        } else if (state.isClosed()) {
            Log.e("OnsessionStateChange", "--State closed----");

        }
    }

Logcat

03-15 14:02:28.804: E/signInWithFacebook(1168): ------->>1.1
03-15 14:02:28.914: I/dalvikvm(1168): threadid=3: reacting to signal 3
03-15 14:02:28.994: I/dalvikvm(1168): Wrote stack traces to '/data/anr/traces.txt'
03-15 14:02:29.434: I/dalvikvm(1168): threadid=3: reacting to signal 3
03-15 14:02:29.494: I/dalvikvm(1168): Wrote stack traces to '/data/anr/traces.txt'
03-15 14:02:29.654: D/FacebookSDK.WebDialog(1168): Webview loading URL: https://m.facebook.com/dialog/oauth?type=user_agent&redirect_uri=fbconnect%3A%2F%2Fsuccess&display=touch&client_id=366325773475096
03-15 14:02:33.424: D/dalvikvm(1168): GC_CONCURRENT freed 133K, 3% free 9854K/10119K, paused 6ms+6ms
03-15 14:02:33.865: D/FacebookSDK.WebDialog(1168): Redirect URL: http://m.facebook.com/login.php?app_id=366325773475096&skip_api_login=1&cancel=fbconnect%3A%2F%2Fsuccess%3Ferror_reason%3Duser_denied%26error%3Daccess_denied%26error_description%3DThe%2Buser%2Bdenied%2Byour%2Brequest.&fbconnect=1&next=https%3A%2F%2Fm.facebook.com%2Fdialog%2Fpermissions.request%3F_path%3Dpermissions.request%26app_id%3D366325773475096%26client_id%3D366325773475096%26redirect_uri%3Dfbconnect%253A%252F%252Fsuccess%26display%3Dtouch%26type%3Duser_agent%26fbconnect%3D1%26from_login%3D1&rcount=1&_rdr
03-15 14:02:33.874: D/FacebookSDK.WebDialog(1168): Webview loading URL: http://m.facebook.com/login.php?app_id=366325773475096&skip_api_login=1&cancel=fbconnect%3A%2F%2Fsuccess%3Ferror_reason%3Duser_denied%26error%3Daccess_denied%26error_description%3DThe%2Buser%2Bdenied%2Byour%2Brequest.&fbconnect=1&next=https%3A%2F%2Fm.facebook.com%2Fdialog%2Fpermissions.request%3F_path%3Dpermissions.request%26app_id%3D366325773475096%26client_id%3D366325773475096%26redirect_uri%3Dfbconnect%253A%252F%252Fsuccess%26display%3Dtouch%26type%3Duser_agent%26fbconnect%3D1%26from_login%3D1&rcount=1&_rdr
03-15 14:02:42.003: D/FacebookSDK.WebDialog(1168): Webview loading URL: http://m.facebook.com/login.php?app_id=366325773475096&skip_api_login=1&cancel=fbconnect%3A%2F%2Fsuccess%3Ferror_reason%3Duser_denied%26error%3Daccess_denied%26error_description%3DThe%2Buser%2Bdenied%2Byour%2Brequest.&fbconnect=1&next=https%3A%2F%2Fm.facebook.com%2Fdialog%2Fpermissions.request%3F_path%3Dpermissions.request%26app_id%3D366325773475096%26client_id%3D366325773475096%26redirect_uri%3Dfbconnect%253A%252F%252Fsuccess%26display%3Dtouch%26type%3Duser_agent%26fbconnect%3D1%26from_login%3D1&rcount=1&_rdr
03-15 14:04:11.173: W/webcoreglue(1168): updateFrameCache: pending style recalc, ignoring.
03-15 14:04:53.154: D/FacebookSDK.WebDialog(1168): Webview loading URL: https://m.facebook.com/login.php?fbconnect=1&skip_api_login=1&next=https%3A%2F%2Fm.facebook.com%2Fdialog%2Fpermissions.request%3F_path%3Dpermissions.request%26app_id%3D366325773475096%26client_id%3D366325773475096%26redirect_uri%3Dfbconnect%253A%252F%252Fsuccess%26display%3Dtouch%26type%3Duser_agent%26fbconnect%3D1%26from_login%3D1&refsrc=http%3A%2F%2Fm.facebook.com%2Flogin.php&app_id=366325773475096&cancel=fbconnect%3A%2F%2Fsuccess%3Ferror_reason%3Duser_denied%26error%3Daccess_denied%26error_description%3DThe%2Buser%2Bdenied%2Byour%2Brequest.&refid=9
03-15 14:04:57.024: D/FacebookSDK.WebDialog(1168): Redirect URL: https://m.facebook.com/dialog/permissions.request?_path=permissions.request&app_id=366325773475096&client_id=366325773475096&redirect_uri=fbconnect%3A%2F%2Fsuccess&display=touch&type=user_agent&fbconnect=1&from_login=1&refid=9&_rdr
03-15 14:04:57.024: D/FacebookSDK.WebDialog(1168): Webview loading URL: https://m.facebook.com/dialog/permissions.request?_path=permissions.request&app_id=366325773475096&client_id=366325773475096&redirect_uri=fbconnect%3A%2F%2Fsuccess&display=touch&type=user_agent&fbconnect=1&from_login=1&refid=9&_rdr
03-15 14:04:57.114: W/chromium(1168): external/chromium/net/spdy/spdy_session.cc:1058: [0315/140457:WARNING:spdy_session.cc(1058)] Received data frame for invalid stream 1
03-15 14:05:19.424: D/dalvikvm(1168): GC_CONCURRENT freed 353K, 5% free 9890K/10375K, paused 6ms+24ms
03-15 14:05:39.163: D/FacebookSDK.WebDialog(1168): Webview loading URL: https://m.facebook.com/dialog/permissions.request
03-15 14:05:40.604: D/FacebookSDK.WebDialog(1168): Redirect URL: fbconnect://success#access_token=AAAFNK92ZAnRgBAGkKgfOETJuxdfpZAta6DAiZCM1RNZCLzgq6XNhDNG9dPAtx0bZBskLW6jtdhx7cDi1ENlmfiBjbdEzuZC5s8933VlcE0cQZDZD&expires_in=5184000&code=AQCo4tQ-KYAZVHSkZZlECsJADz5SnYH4PSlJROB6LQL2OssTrtOFYQc80znkbJFX0zFYS73qFHF-w52QJvFVajwOqmlbe8UcIslhggk77b63IILQ-pKNgdUuxzZbXRQQvd31kAoB7CRSeW9ImNPPwPD2-lI_l2UlyA6sbtRERMzZncHwKoKyWnwsfsGFiAh6CPyVPoFFYUAWrTVK5pTsp8EB
03-15 14:05:41.313: I/dalvikvm(1168): threadid=3: reacting to signal 3
03-15 14:05:41.483: I/dalvikvm(1168): Wrote stack traces to '/data/anr/traces.txt'
03-15 14:05:41.873: E/signInWithFacebook(1168): ------->>1.1
03-15 14:05:41.873: E/OnsessionStateChange(1168): ------
03-15 14:05:41.873: E/OnsessionStateChange(1168): --State opened----
03-15 14:05:42.913: I/dalvikvm(1168): threadid=3: reacting to signal 3
03-15 14:05:43.083: I/dalvikvm(1168): Wrote stack traces to '/data/anr/traces.txt'
03-15 14:05:43.324: D/FacebookSDK.WebDialog(1168): Webview loading URL: https://m.facebook.com/dialog/oauth?display=touch&client_id=366325773475096&scope=email&type=user_agent&redirect_uri=fbconnect%3A%2F%2Fsuccess
03-15 14:05:43.423: I/dalvikvm(1168): threadid=3: reacting to signal 3
03-15 14:05:43.483: I/dalvikvm(1168): Wrote stack traces to '/data/anr/traces.txt'
03-15 14:05:43.743: D/FacebookSDK.WebDialog(1168): Redirect URL: http://m.facebook.com/login.php?app_id=366325773475096&skip_api_login=1&cancel=fbconnect%3A%2F%2Fsuccess%3Ferror_reason%3Duser_denied%26error%3Daccess_denied%26error_description%3DThe%2Buser%2Bdenied%2Byour%2Brequest.&fbconnect=1&next=https%3A%2F%2Fm.facebook.com%2Fdialog%2Fpermissions.request%3F_path%3Dpermissions.request%26app_id%3D366325773475096%26client_id%3D366325773475096%26redirect_uri%3Dfbconnect%253A%252F%252Fsuccess%26display%3Dtouch%26type%3Duser_agent%26perms%3Demail%26fbconnect%3D1%26from_login%3D1&rcount=1&_rdr
03-15 14:05:43.933: I/dalvikvm(1168): threadid=3: reacting to signal 3
03-15 14:05:44.045: I/dalvikvm(1168): Wrote stack traces to '/data/anr/traces.txt'
03-15 14:05:44.283: D/FacebookSDK.WebDialog(1168): Webview loading URL: http://m.facebook.com/login.php?app_id=366325773475096&skip_api_login=1&cancel=fbconnect%3A%2F%2Fsuccess%3Ferror_reason%3Duser_denied%26error%3Daccess_denied%26error_description%3DThe%2Buser%2Bdenied%2Byour%2Brequest.&fbconnect=1&next=https%3A%2F%2Fm.facebook.com%2Fdialog%2Fpermissions.request%3F_path%3Dpermissions.request%26app_id%3D366325773475096%26client_id%3D366325773475096%26redirect_uri%3Dfbconnect%253A%252F%252Fsuccess%26display%3Dtouch%26type%3Duser_agent%26perms%3Demail%26fbconnect%3D1%26from_login%3D1&rcount=1&_rdr
03-15 14:05:45.323: D/dalvikvm(1168): GC_CONCURRENT freed 293K, 5% free 10019K/10439K, paused 6ms+7ms
03-15 14:05:47.924: D/FacebookSDK.WebDialog(1168): Webview loading URL: http://m.facebook.com/login.php?app_id=366325773475096&skip_api_login=1&cancel=fbconnect%3A%2F%2Fsuccess%3Ferror_reason%3Duser_denied%26error%3Daccess_denied%26error_description%3DThe%2Buser%2Bdenied%2Byour%2Brequest.&fbconnect=1&next=https%3A%2F%2Fm.facebook.com%2Fdialog%2Fpermissions.request%3F_path%3Dpermissions.request%26app_id%3D366325773475096%26client_id%3D366325773475096%26redirect_uri%3Dfbconnect%253A%252F%252Fsuccess%26display%3Dtouch%26type%3Duser_agent%26perms%3Demail%26fbconnect%3D1%26from_login%3D1&rcount=1&_rdr
03-15 14:06:01.764: W/myConsultant(1168): 100003532434600 Nest Nest {"hometown":{"id":"111955358823868","name":"Thiruvananthapuram, Kerala"},"location":{"id":"111955358823868","name":"Thiruvananthapuram, Kerala"},"locale":"en_US","link":"http:\/\/www.facebook.com\/iosdev.nest","updated_time":"2013-03-15T08:23:37+0000","id":"100003532434600","languages":[{"id":"106059522759137","name":"English"},{"id":"112969428713061","name":"Hindi"},{"id":"105692839465644","name":"Malayalam"}],"first_name":"Nest","timezone":5.5,"username":"iosdev.nest","bio":"Developer","verified":true,"name":"Nest Dev","favorite_teams":[{"id":"107844962567241","name":"Chennai Super Kings"}],"last_name":"Dev","gender":"male","favorite_athletes":[{"id":"113041012044041","name":"P. T. Usha"}]}
03-15 14:06:01.764: D/user email(1168): nulllinkhttp://www.facebook.com/iosdev.nest
4

1 に答える 1

0

別の ME リクエストを送信する代わりに、Facebook の LoginButton を使用し、フックを追加してユーザー情報をインターセプトします。

// Intercept the facebook user returned from login
facebookLoginButton.setUserInfoChangedCallback(new LoginButton.UserInfoChangedCallback() {

    @Override
    public void onUserInfoFetched(GraphUser user) {
        mFacebookUser = user;

        if (user != null) {
            LogUtils.LOGFB(TAG, "Got a Facebook user: " + user.getFirstName() +
                    " " + user.getLastName() + ", email: " + user.getProperty("email"));
        }
        else {
            LogUtils.LOGFB(TAG, "No Facebook user");
        }
    }
});

追加の読み取り権限として電子メールも追加する必要があります。

facebookLoginButton.setReadPermissions(Arrays.asList(
        "email", "user_birthday", ...));
于 2014-01-03T19:50:12.040 に答える