Parse.com Facebook API的logIn()方法。(Parse.com Facebook API logIn() method. Callback never gets called)

系统教程 行业动态 更新时间:2024-06-14 16:57:40
Parse.com Facebook API的logIn()方法。(Parse.com Facebook API logIn() method. Callback never gets called)

当我的点击处理程序在客户端上调用logIn()函数时,我看到一个FB弹出窗口和一个在User集合中创建的记录,但回调方法从不会被调用。 相反,我在JS控制台中看到以下内容

Uncaught TypeError: Cannot read property 'getTime' of null parse-1.2.18.min.js:3

这是我的页面上的代码

设置FB API

<script> window.fbAsyncInit = function() { Parse.FacebookUtils.init({ appId : 757503280935086, xfbml : true, version : 'v2.0' }); }; (function(d, s, id){ var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script>

调用登录方法

$scope.signupFB = function() { Parse.FacebookUtils.logIn(null, { success: function(user) { //never get here $timeout(function() { $rootScope.theUser = user; $location.path("/properties"); }); }, error: function(user, error) { $scope.error = "User cancelled the Facebook login or did not fully authorize."; } }); }

FB应用程序启用了“平台”网站。

下次我尝试着看到

Uncaught Error: Setting authResponse is not supported

在JS控制台。

When my click handler calls logIn() function on a client, I see a FB popup and a record being created in User collection, but callback methods are never called. Instead, I see the following in JS console

Uncaught TypeError: Cannot read property 'getTime' of null parse-1.2.18.min.js:3

Here is the code on my page

Setting up FB API

<script> window.fbAsyncInit = function() { Parse.FacebookUtils.init({ appId : 757503280935086, xfbml : true, version : 'v2.0' }); }; (function(d, s, id){ var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script>

Calling login method

$scope.signupFB = function() { Parse.FacebookUtils.logIn(null, { success: function(user) { //never get here $timeout(function() { $rootScope.theUser = user; $location.path("/properties"); }); }, error: function(user, error) { $scope.error = "User cancelled the Facebook login or did not fully authorize."; } }); }

The FB app has a website "Platform" enabled.

Next time I tried I saw

Uncaught Error: Setting authResponse is not supported

in JS console.

最满意答案

问题来自使用v2 facebook api。

切换到与Timothy的修复旧版本的作品。

window.fbAsyncInit = function() { Parse.FacebookUtils.init({ appId : '' // Facebook App ID }); }; (function(d, s, id){ var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));

注意包括all.js而不是sdk.js

The problem comes from using the v2 facebook api.

Switching to the old version with Timothy's fix works.

window.fbAsyncInit = function() { Parse.FacebookUtils.init({ appId : '' // Facebook App ID }); }; (function(d, s, id){ var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));

Notice including all.js not sdk.js

更多推荐

本文发布于:2023-04-13 12:09:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/1617ff32051164e25ff58d11776a6b1f.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方法   API   Parse   Facebook   logIn

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!