Parse platform 通过Parse&;Javascript
我希望在用户单击链接后显示facebook登录/注册框,但它不起作用。Parse应该用自己的init函数加载FB-SDK,并用自己的另一个函数显示登录框。我直接从他们的文档中复制并粘贴了这些代码,所以我认为这不是语法问题。我还尝试在不同的地方初始化Parse SDK,但这似乎无关紧要。我知道jquery函数正在工作,因为我已经用警报函数对它进行了测试,当我单击目标链接时,它就会启动,但登录框不会显示。Parse platform 通过Parse&;Javascript,parse-platform,facebook-javascript-sdk,Parse Platform,Facebook Javascript Sdk,我希望在用户单击链接后显示facebook登录/注册框,但它不起作用。Parse应该用自己的init函数加载FB-SDK,并用自己的另一个函数显示登录框。我直接从他们的文档中复制并粘贴了这些代码,所以我认为这不是语法问题。我还尝试在不同的地方初始化Parse SDK,但这似乎无关紧要。我知道jquery函数正在工作,因为我已经用警报函数对它进行了测试,当我单击目标链接时,它就会启动,但登录框不会显示。 我需要修理什么 > //初始化解析SDK! Parse.initialize(“******
我需要修理什么 >
//初始化解析SDK!
Parse.initialize(“**********”,“*************”);
window.fbAsyninit=函数(){
//通过解析初始化Facebook SDK
Parse.FacebookUtils.init({
appId:“**********”,//应用程序仪表板中的应用程序ID
频道URL:'//http://spilot.koding.com/channel.html“,//用于x域通信的通道文件
status:true,//在初始化时检查登录状态?
cookie:true,//设置会话cookie以允许服务器访问会话?
xfbml:true//是否解析此页面上的xfbml标记?
});
//附加的初始化代码(如添加事件侦听器)如下所示
//用户单击链接后,使用Parse SDK显示Facebook登录/注册框
$(“a”)。单击(函数(){
Parse.FacebookUtils.logIn(null{
成功:功能(用户){
如果(!user.existed()){
警报(“用户注册并通过Facebook登录!”);
}否则{
警报(“用户通过Facebook登录!”);
}
},
错误:函数(用户,错误){
警报(“用户取消了Facebook登录或未完全授权”);
}
});
});
//异步加载SDK的源代码
//请注意,调试版本正在积极开发中,可能
//包含一些过于严格的类型检查。
//请使用bug工具报告此类bug。
(功能(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”+(debug?/debug):“)+”.js”;
ref.parentNode.insertBefore(js,ref);
}(文档,/*debug*/false));
>
//首先初始化解析对象。
初始化(“XXXXXXXXX”,“YYYYYYYYYY”);
window.fbAsyninit=函数(){
Parse.FacebookUtils.init({
appId:'zzzzzzzzzzz',
状态:正确,
曲奇:是的,
xfbml:对
});
Parse.FacebookUtils.logIn(null{
成功:功能(用户){
如果(!user.existed()){
警报(“用户注册并通过Facebook登录!”);
}否则{
警报(“用户通过Facebook登录!”);
}
},
错误:函数(用户,错误){
警报(“用户取消了Facebook登录或未完全授权”);
}
});
};
(职能(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);
}(文件);
但这将如何由按钮触发,例如?
<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>
>
<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>