App Domains: localhost
Website with Facebook login: http://localhost/auth
我转到http://localhost/auth/
并在我的Chrome开发者控制台中看到错误:Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.
我做了一个view-source看到以下内容:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<div id="fb-root"></div>
<script>
// Additional JS functions here
window.fbAsyncInit = function() {
FB.init({
appId : 'myappidremovedfromstackoverflowquestion', // App ID
channelUrl : '//localhost/auth/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 init 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>
<p>hello</p>
</body>
</html>
我转到http://localhost/auth/channel.html
并查看来源以查看单行:
<script src="//connect.facebook.net/en_US/all.js"></script>
答案 0 :(得分:11)
如果要将Facebook应用程序与本地环境连接,则应使用某些别名域。
尝试以下方法:
转到您的etc/hosts
(或%systemroot%/system32/drivers/etc/hosts
)文件并添加以下行:
127.0.0.1 foo.local # alias domain
转到App > Settings
并使用foo.local
作为应用域注册您的应用。
添加您的网站网址(例如http://foo.local/project/)
完成。
于2016年1月16日编辑:
Facebook改变了他们的用户界面,按照以下步骤使其有效。
App > Settings > Basic (tab)
Add Platform
,选择“网站”并输入您的别名域。App Domain
部分添加您的域名。