当我的点击处理程序在客户端上调用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:3Here 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 supportedin 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
更多推荐
发布评论