2

を拡張するクラスがありますListFragment。私のloginToFacebook()方法(以下を参照)は機能します。しかし、ログアウトして を呼び出すとlogoutFromFacebook()、次のエラーが表示されます。

{"error_code":101,"error_msg":"Invalid application ID.","request_args":[{"key":"method","value":"auth.expireSession"},{"key":"format","value":"json"}]}

ここに私の方法があります:

public void loginToFacebook() {

        mPrefs = getPreferences(MODE_PRIVATE);
        String access_token = mPrefs.getString("access_token", null);
        long expires = mPrefs.getLong("access_expires", 0);

        if (access_token != null) {
            facebook.setAccessToken(access_token);

            btnFbLogin.setVisibility(View.INVISIBLE);

            // Making get profile button visible
            btnFbGetProfile.setVisibility(View.VISIBLE);

            // Making post to wall visible
            btnPostToWall.setVisibility(View.VISIBLE);

            // Making show access tokens button visible
            btnShowAccessTokens.setVisibility(View.VISIBLE);

            btnLogout.setVisibility(View.VISIBLE);

            Log.d("FB Sessions", "" + facebook.isSessionValid());
        }

        if (expires != 0) {
            facebook.setAccessExpires(expires);
        }

        if (!facebook.isSessionValid()) {
            facebook.authorize(getActivity(),
                    new String[] { "email", "publish_stream" },
                    new DialogListener() {

                        @Override
                        public void onCancel() {
                            // Function to handle cancel event
                        }

                        @Override
                        public void onComplete(Bundle values) {
                            // Function to handle complete event
                            // Edit Preferences and update facebook acess_token
                            SharedPreferences.Editor editor = mPrefs.edit();
                            editor.putString("access_token",
                                    facebook.getAccessToken());
                            editor.putLong("access_expires",
                                    facebook.getAccessExpires());
                            editor.commit();

                            // Making Login button invisible
                            btnFbLogin.setVisibility(View.INVISIBLE);

                            // Making logout Button visible
                            btnFbGetProfile.setVisibility(View.VISIBLE);

                            // Making post to wall visible
                            btnPostToWall.setVisibility(View.VISIBLE);

                            // Making show access tokens button visible
                            btnShowAccessTokens.setVisibility(View.VISIBLE);

                            btnLogout.setVisibility(View.VISIBLE);
                        }

                        @Override
                        public void onError(DialogError error) {
                            // Function to handle error

                        }

                        @Override
                        public void onFacebookError(FacebookError fberror) {
                            // Function to handle Facebook errors

                        }

                    });
        }
    }

//-------------------------------------//

public void logoutFromFacebook() {
        mAsyncRunner.logout(getActivity(), new RequestListener() {
            @Override
            public void onComplete(String response, Object state) {
                Log.d("Logout from Facebook", response);
                if (Boolean.parseBoolean(response) == true) {
                    runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            // make Login button visible
                            btnFbLogin.setVisibility(View.VISIBLE);

                            // making all remaining buttons invisible
                            btnFbGetProfile.setVisibility(View.INVISIBLE);
                            btnPostToWall.setVisibility(View.INVISIBLE);
                            btnShowAccessTokens.setVisibility(View.INVISIBLE);
                            btnLogout.setVisibility(View.INVISIBLE);
                        }

                    });

                }
            }

            @Override
            public void onIOException(IOException e, Object state) {
            }

            @Override
            public void onFileNotFoundException(FileNotFoundException e,
                    Object state) {
            }

            @Override
            public void onMalformedURLException(MalformedURLException e,
                    Object state) {
            }

            @Override
            public void onFacebookError(FacebookError e, Object state) {
            }
        });
    }

問題の原因は ではないかと思いextends ListFragmentますextends Activity

誰かがこの問題を解決するために私を助けてくれますか? どんな助けでもいただければ幸いです。

ありがとうございました

4

0 に答える 0