https://parse.com/docs/js_guide#fbusers (Javascript を使用した Facebook ログイン)の手順を使用して、Facebook 認証を使用するログイン ページを作成しました。
最初にログインすると、すべてが完璧に機能します (コンソールで「FB.init は既に呼び出されています」という警告を除いて)。
ページを更新すると、コンソールに「FB.login() Called when user is already connected」というエラーが表示されます。しかし、期待どおりに「ユーザーが Facebook からログインしました」というメッセージが表示されます。
再度更新を押すと、「ユーザーが Facebook のログインをキャンセルしたか、完全に承認しませんでした」というメッセージ ボックスが表示されます (Msgbox はコードで定義されています)。コンソールには、https://apiへの POST が表示されます。 .parse.com/1/usersは、以前は 200 OK だったのに対し、400 エラーを返しました。
これは私の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>
誰かが問題を発見できれば幸いです。ありがとう!