使用Parse登录Facebook,但我得到--https://api.parse.com/1/users404--刷新

Using Parse for Facebook login but i get --https://api.parse.com/1/users 404-- After Refreshing 3 Times

本文关键字:api parse com 刷新 users404-- --https Facebook 登录 Parse 使用      更新时间:2023-09-26

I在此处使用了说明:https://parse.com/docs/js_guide#fbusers(使用Javascript登录Facebook)来编写使用Facebook身份验证的登录页面。

当我第一次登录时,一切都很好(除了控制台中的"FB.init已经被调用"警告。)

当我刷新页面时,我在控制台中看到一个"当用户已经连接时调用FB.login()"错误。但我仍然会收到一条"用户通过Facebook登录"的消息。

如果我再次点击刷新,我现在会收到一个消息框,上面写着"用户取消了facebook登录或没有完全授权"(Msgbox在代码中定义),在控制台中,我现在看到POSThttps://api.parse.com/1/users返回了一个400错误,而之前我得到了200 OK。

这是我的HTML代码:

<html><head></head><body> <div id="fb-root"></div> 
<script src="http://www.parsecdn.com/js/parse-1.2.9.min.js"></script>
<script>Parse.initialize("<key>", "<key>"); // Additional JS functions here 
window.fbAsyncInit = function() {
   Parse.FacebookUtils.init({
   appId      : '<id>', // App ID
   channelUrl : '<path>/Channel.html', // Channel File
   status     : true, // check login status
   cookie     : true, // enable cookies to allow the server to access the session
   xfbml      : true  // parse XFBML
 });
 Parse.FacebookUtils.logIn(null, {
     success: function(user) {
     if (!user.existed()) {
        alert("User signed up and logged in through Facebook!");
     } else {
        alert("User logged in through Facebook!");
     }
     },
        error: function(user, error) {
          alert("User cancelled the Facebook login or did not fully authorize.");
     }
  });
}; 
// Load the SDK asynchronously 
(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')); 
</script> 
<fb:login-button show-faces="true"    width="200" max-rows="1"></fb:login-button>
</body> </html>

如果有人能发现这个问题,我将不胜感激。谢谢

"用户取消了facebook登录或未完全授权"表示您已经登录。使用chrome的开发工具控制台检查您的当前用户是否使用此命令:

Parse.User.current()

如果你得到一个对象,你已经登录了。

您可以使用Parse.User.logOut()注销,那么Parse.User.current()应该返回一个null!

你也可以使用Parse.User.current().get('authData')['facebook'],如这里提到的

注意事项:如果从parse注销会将您从facebook注销,请更新您的解析参考