Facebook认证与Facebook应用程序错误 [英] Facebook Authentication with Facebook app error

查看:128
本文介绍了Facebook认证与Facebook应用程序错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循此处的说明,并且可以正常工作,当没有安装Facebook App。当安装官方的Facebook应用程序时,调用 authorize 后,不会调用回调,并且我没有收回令牌。当安装该应用程序时,闪亮的登录屏幕出现(从Facebook应用程序),而不是Webview。
我搜索了很多,但每个教程都说我应该使用我链接的页面中的样本。我缺少什么?

I followed the instructions here, and it works fine, when the Facebook App is not installed. When the official Facebook App is installed, the callback are not called after calling authorize, and I don't get back the token. When the app is installed, the shiny login screen comes up (from the Facebook app), when it's not, the webview. I searched a lot, but every tutorial says I should use the sample from the page I linked. What am I missing?

// Facebook connect
public void facebookConnect(View v) {
    /* CocktailflowTest AppID */
    final Facebook facebook = new Facebook("134370943293463");
    facebook.authorize(this, new String[] { "email", "offline_access" }, new DialogListener() {

        @Override
        public void onFacebookError(FacebookError e) {
            e.getMessage();
        }

        @Override
        public void onError(DialogError e) {
            Toast.makeText(LaunchActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onComplete(Bundle values) {
            mFBToken = facebook.getAccessToken();
            getPreferences(MODE_PRIVATE).edit().putString(Prefs.FACEBOOK_TOKEN, mFBToken).commit();
            WebService service = new WebService();
            WebServiceListener l = new LaunchWebserviceListener();
            mDialog = ProgressDialog.show(LaunchActivity.this, "", "Logging in...");
            mDialog.show();
            service.connectWithFacebook(l, mFBToken);
        }

        @Override
        public void onCancel() {
            Log.i(TAG, "Facebook connect was cancelled by user.");
        }
    });
}


推荐答案

您需要覆盖onActivityResult您的活动中的方法:

You need to override the onActivityResult method in your Activity:

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

这篇关于Facebook认证与Facebook应用程序错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆