我正在尝试在为 Android 制作的 PhoneGap 项目中通过 Parse 登录 Facebook。
当我尝试在本地运行 HTML 时,会出现弹出窗口,但我收到一般的“发生错误”消息。当我运行 Android 项目时,Facebook 弹出/重定向甚至不会出现。
<script type="text/javascript" charset="utf-8" src="cordova-1.9.0.js"></script>
<script src="http://www.parsecdn.com/js/parse-1.0.8.min.js"></script>
<script>
Parse.initialize("XXXXXXX",
"YYYYYY");
</script>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
Parse.FacebookUtils.init({
appId : 'ZZZZZZZ', // App ID
channelUrl : '//WWW.YOUR_DOMAIN.COM/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
});
// Additional initialization code here
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){
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>
<h1>Hello World</h1>
</body>
</html>
所以,我很想让这个工作。提前感谢您的帮助!:)
更新 - 这是我得到的错误信息:
API错误代码:191 API错误描述:指定的URL不属于应用程序错误消息:无效的redirect_uri:应用程序配置不允许给定的URL。