我看了:https://www.parse.com/docs/js_guide#fbusers
我实施了
<script>
// Initialize Parse
Parse.initialize("--", "--");
window.fbAsyncInit = function() {
Parse.FacebookUtils.init({ // this line replaces FB.init({
appId : '{--}', // Facebook App ID
status : true, // check Facebook Login status
cookie : true, // enable cookies to allow Parse to access the session
xfbml : true
});
Parse.FacebookUtils.logIn("public_profile,user_likes,email", {
success: function(user) {
if (!user.existed()) {
alert("User signed up and logged in through Facebook!");
console.log("user already exists ***";
} else {
console.log("new user created");
alert("User logged in through Facebook! ***");
}
console.log("facebook parse activated ***");
},
error: function(user, error) {
alert("User cancelled the Facebook login or did not fully authorize.");
}
});
// Run code after the Facebook SDK is loaded.
};
(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>
什么都没出现,我做错了什么。我想要求用户提供权限并强制他们登录。
由于
答案 0 :(得分:0)
我认为问题在于您没有正确登录。这有用吗?
Parse.FacebookUtils.logIn({
"id": "user's Facebook id number as a string",
"access_token": "an authorized Facebook access token for the user",
"expiration_date": "token expiration date of the format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
}, {
success: function(user) {
if (!user.existed()) {
alert("User signed up and logged in through Facebook!");
console.log("user already exists ***";
} else {
console.log("new user created");
alert("User logged in through Facebook! ***");
}
console.log("facebook parse activated ***");
},
error: function(user, error) {
alert("User cancelled the Facebook login or did not fully authorize.");
}
});