我想登录facebook这里是我的代码:
<body>
<form id="form1" runat="server">
<div id="fb-root"></div>
<script>
(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_GB/all.js#xfbml=1&appId=221385331301885";
fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'facebook-jssdk'));
</script>
<div class="fb-login-button" data-show-faces="false" data-width="300"></div>
<script>
window.fbAsyncInit = function () {
FB.init({
appId: '221385323101885', // App ID
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
};
// 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>
</form>
</body>
当我运行此代码时,我收到以下错误消息:
我尝试使用https://developers.facebook.com/tools/debug调试窗口中的网址但是它一直告诉我网址不可废弃:/如果你想尝试调试它,网址如下:
https://www.facebook.com/dialog/oauth?api_key=221385331301885&app_id=221385331301885&client_id=221385331301885&display=popup&domain=127.0.0.1&locale=en_GB&origin=1&redirect_uri=https%3A%2F%2Fs-static.ak.fbcdn.net%2Fconnect%2Fxd_proxy.php%23cb%3Df4b3e7f08%26origin%3Dhttp%253A%252F%252F127.0.0.1%253A81%252Ff22a06766%26relation%3Dopener%26transport%3Dpostmessage%26frame%3Df23609e538&response_type=token%2Csigned_request&sdk=joey
我更改了我的hosts文件,为127.0.0.1 localhost.local添加了一个条目,以匹配我的Facbook App设置。以下是我的主机文件和我的Facebook应用程序设置的屏幕截图:
正如您所看到的,主机文件和Facebook应用设置中的域名相同。关于如何解决这个问题的任何想法?感谢
答案 0 :(得分:3)
我想我找到了你的问题,但我不确定为什么会这样......
我尝试完全按照您的操作完成,但使用移动网络,我在网站选项中有 http:// localhost (而且手机是空的)。一切都很好。
当我将其从网站切换到移动网络时,我收到您报告的相同错误。 您 是否使用移动选项?
此外,您正在加载fb sdk两次,不知道为什么,第一次使用此来源:
// connect.facebook.net/en_GB/all.js#xfbml=1&appId=221385331301885
然后再使用这个来源:
“// connect.facebook.net/en_US/all.js”
重点是什么?简单地这样做有什么问题:
<div id="fb-root"></div>
<div class="fb-login-button" data-show-faces="false" data-width="300"></div>
<script>
window.fbAsyncInit = function () {
FB.init({
appId: '221385323101885', // App ID
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
};
// 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>
希望它能解决你的问题。
答案 1 :(得分:3)
添加Site URL : http://localhost
为我工作
答案 2 :(得分:0)
现在您必须在Apache
中创建虚拟主机