3
this.FBlogin = function() {
    console.log("TEST");

    FB.login(
            function(response) {

                console.log(response);

                if (response.session) {
                    console.log(response.session);
                } else {
                    console.log('not logged in');
                }
            },
            { scope: "user_about_me, user_activities, user_birthday, user_hometown, user_interests, user_location, user_religion_politics, user_status, user_website, offline_access, email" }
    );
}

logCat 中仅打印 TEST:

02-01 00:09:30.616: D/CordovaLog(1489): file:///android_asset/www/js/cdv-plugin-fb-connect.js: Line 24 : Cordova Facebook Connect plugin initialized successfully.
02-01 00:09:30.616: I/Web Console(1489): Cordova Facebook Connect plugin initialized successfully. at file:///android_asset/www/js/cdv-plugin-fb-connect.js:24
02-01 00:09:32.096: D/DroidGap(1489): onMessage(spinner,stop)
02-01 00:09:33.907: D/(1489): HostConnection::get() New Host Connection established 0x93e9038, tid 1526
02-01 00:09:48.106: D/CordovaLog(1489): TEST
02-01 00:09:48.106: D/CordovaLog(1489): file:///android_asset/www/js/auth.js: Line 148 : TEST
02-01 00:09:48.106: I/Web Console(1489): TEST at file:///android_asset/www/js/auth.js:148
02-01 00:09:48.185: D/dalvikvm(1489): GC_CONCURRENT freed 56K, 2% free 10199K/10375K, paused 4ms+3ms
02-01 00:09:48.386: D/DroidGap(1489): Paused the application!
02-01 00:09:48.386: D/CordovaWebView(1489): Handle the pause
02-01 00:09:49.025: I/dalvikvm(1489): threadid=3: reacting to signal 3
02-01 00:09:49.055: I/dalvikvm(1489): Wrote stack traces to '/data/anr/traces.txt'
02-01 00:09:49.145: W/EGL_emulation(1489): eglSurfaceAttrib not implemented
02-01 00:09:49.595: D/OpenGLRenderer(1489): Flushing caches (mode 0)
02-01 00:09:55.026: D/DroidGap(1489): Resuming the App

似乎我被重定向到了 FB 应用程序,但我只在顶部栏中看到 AppId 和一个显示“facebook”的警报框。我的应用程序已暂停,回来后未调用成功处理程序?有大佬知道为什么吗?或者如何调试?

PS appId 已正确添加到 strings.xml。生成密钥哈希并将其添加到 FB,以及包和类名。我错过了什么吗?

PPS 使用:Phonegap 2.2。以及 phonegap-plugin-facebook-connect 库的相应分支:https ://github.com/davejohnson/phonegap-plugin-facebook-connect/tree/cordova-2.2-facebook-android-3.0

4

4 回答 4

7

好的,它似乎也是范围的问题。更改为仅电子邮件后,将执行成功函数回调。

{ scope: "email" }

另见:https ://github.com/davejohnson/phonegap-plugin-facebook-connect/issues/240

注意示例已过时:

response.session

改用以下内容:

response.authResponse.accessToken
response.authResponse.session_key
response.authResponse.expiresIn
response.authResponse.userId
response.authResponse.sig
response.authResponse.expirationTime
response.status

它是 OAuth2 处理:参见https://developers.facebook.com/blog/post/2011/07/21/updated-javascript-sdk-and-oauth-2-0-roadmap/

于 2013-02-03T19:32:24.530 回答
2

你在使用 Phonegap Build / Build Facebook Plugin 吗?

您是否在任何其他 Facebook 调用之前正确调用 FB.init() ?

你所有的范围都拼写正确吗?

于 2013-04-25T21:43:18.410 回答
0

{ scope: "email" } 你必须输入回调,否则它不会被执行。这是一个工作示例

facebook使用cordova cli 3.3连接

于 2014-02-15T03:21:15.940 回答
0

我已经完成了所有步骤,第一次登录工作完美。

登录后,应用程序不起作用,当它重新启动时,我得到 Invaid android_key 参数错误。

哈希键在 FB App 中配置。我正在使用 Phonegap Build 3.0

于 2014-05-05T12:35:49.193 回答