Spi*_*lot 0 facebook-javascript-sdk parse-platform
我希望在用户点击链接后显示facebook登录/注册框,但它不起作用.Parse应该使用自己的init函数加载FB SDK,并且应该使用自己的另一个函数显示登录框.我直接从他们的文档中复制并粘贴了代码,因此我认为这不是语法问题.我也尝试在不同的地方初始化Parse SDK,但似乎并不重要.我知道jquery函数正在运行,因为我已经使用警报功能测试它,当我点击目标链接时它会触发,但是登录框不会显示.
我需要修理什么?
>
<body>
<div id="fb-root"></div>
<script>
// Initialize the Parse SDK!
Parse.initialize("***********","***********");
window.fbAsyncInit = function() {
//initialize Facebook SDK via Parse
Parse.FacebookUtils.init({
appId : '***********', // App ID from the App DashboardD
channelUrl : '//http://spilot.koding.com/channel.html', // Channel File for x-domain communication
status : true, // check the login status upon init?
cookie : true, // set sessions cookies to allow your server to access the session?
xfbml : true // parse XFBML tags on this page?
});
// Additional initialization code such as adding Event Listeners goes here
// use Parse SDK to show Facebook login/registration box after user clicks link
$("a").click(function(){
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's source Asynchronously
// Note that the debug version is being actively developed and might
// contain some type checks that are overly strict.
// Please report such bugs using the bugs tool.
(function(d, debug){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";
ref.parentNode.insertBefore(js, ref);
}(document, /*debug*/ false));
</script>
<div id="header"></div>
<div id="findScene"><a href=""><h1>Find</h1></a></div>
<div id="startScene"><a href=""><h1>Host</h1></a></div>
<div id="footer"></div>
</body>
>
Run Code Online (Sandbox Code Playgroud)
小智 8
<script type="text/javascript">
// Initialize the Parse object first.
Parse.initialize("XXXXXXXXXX", "YYYYYYYYYYYYY");
window.fbAsyncInit = function() {
Parse.FacebookUtils.init({
appId : 'ZZZZZZZZZZZZZZZ',
status : true,
cookie : true,
xfbml : true
});
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.");
}
});
};
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document)); </script>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4745 次 |
| 最近记录: |