我已经按照本教程:https://developers.facebook.com/docs/reference/javascript/#loading,这是我的IBM Worklight应用程序中的common / myapp.html中的代码:
<!DOCTYPE HTML>
<html xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<meta charset="UTF-8">
<title>Buy3</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
<link rel="shortcut icon" href="images/favicon.png">
<link rel="apple-touch-icon" href="images/apple-touch-icon.png">
<link rel="stylesheet" href="css/Buy3.css">
<script>window.$ = window.jQuery = WLJQ;</script>
</head>
<body id="content" style="display: none;">
<!--application UI goes here-->
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxx', // App ID
channelUrl : 'http://stormy-sands-2143.herokuapp.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
oauth: true
});
};
// Load the SDK asynchronously
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "http://connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
// Here we run a very simple test of the Graph API after login is successful.
// This testAPI() function is only called in those cases.
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
//Log.i(TAG, "Logged in...");
});
}
</script>
<!--Below we include the Login Button social plugin. This button uses the JavaScript SDK to-->
<!--present a graphical Login button that triggers the FB.login() function when clicked.-->
<div id="user-info"></div>
<button id="fb-auth" onclick="FB.login();" >Login</button>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script src="js/initOptions.js"></script>
<script src="js/Buy3.js"></script>
<script src="js/messages.js"></script>
</body>
</html>
以下是我的Facebook应用程序配置中的一些值:
App ID: "XXX"
Display Name: "[blah blah blah]"
Namespace: jfgjfgjhfgjh
App domains:stormy-sands-2143.herokuapp.com
HostingURL: https://stormy-sands-2143.herokuapp.com
Sandbox Mode: "Disable"
Site Url: http://stormy-sands-2143.herokuapp.com/
Canvas Page: http://apps.facebook.com/jfgjfgjhfgjh
Canvas URL: http://stormy-sands-2143.herokuapp.com/
Secure Canvas URL: https://stormy-sands-2143.herokuapp.com/
Page Tab URL: http://stormy-sands-2143.herokuapp.com/
Secure Page Tab URL: https://stormy-sands-2143.herokuapp.com/
请注意,我必须从教程中给出的示例中更改代码底部附近的js.src参数,与我的频道文件中的参数相同。
然后,当我点击登录按钮时,我看到了Facebook登录对话框,我已经输入了电子邮件和密码,然后点击确定,我有错误:
应用程序配置不允许使用URL:一个或 应用程序的设置不允许更多的给定URL。它必须 匹配网站URL或Canvas URL,或域必须是子域 其中一个Apps域名。
我在stackoverflow和google上搜索所有内容但无法解决此错误。 谢谢你的帮助!
答案 0 :(得分:1)
好的我已经知道了,只需删除关于heroku的所有内容,然后按照这样的app配置
App domains:localhost
HostingURL:
Sandbox Mode: "Disable"
Site Url: http://localhost/
Canvas Page: http://apps.facebook.com/jfgjfgjhfgjh
Canvas URL: http://localhost/
Secure Canvas URL: https://localhost/
Page Tab URL: http://localhost/
Secure Page Tab URL: https://localhost/
然后
HTML中的
//channelUrl : 'http://stormy-sands-2143.herokuapp.com/channel.html'
。 对于任何需要它的人