Php 应用程序配置不允许给定URL。:localhost

Php 应用程序配置不允许给定URL。:localhost,php,facebook,oauth,Php,Facebook,Oauth,我正在localhost中测试我的应用程序。当我点击fb登录时,我得到了一个错误 > 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 subdoma

我正在
localhost
中测试我的应用程序。当我点击fb登录时,我得到了一个错误

> 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.
我提到过,但这是关于在线申请的。在这里,我想在本地测试它。在应用程序域中我应该给出什么

我的申请名称是
http://localhost/fblogin.
以及什么应该是重定向\u url

我试图给应用程序域
http://localhost/fblogin
但它给我的错误如下

> App Domains: `https://localhost/fblogin` should not contain protocol information.

我只能通过设置虚拟主机URL在本地测试facebook应用程序。如果您不熟悉虚拟主机,基本效果是,当您在计算机上引导任何浏览器时,您选择的某个URL(如果您愿意,可以是www.yahoo.com)会指向本地目录,而不是在internet上查找该URL。这样,您就可以在保持本地的同时为facebook提供它想要的http://URL。我可以使用以下命令在Mac上设置虚拟主机。

我建议您添加一个开发子域,并将其指向本地主机

在Mac OSX中编辑终端中的/etc/hosts

sudo vi /etc/hosts
然后在文件末尾添加以下行(相应地替换“mydomain.com”)

然后保存,按ESC键

:wq
然后刷新缓存

dscacheutil -flushcache
现在将该域添加到您的facebook应用程序域

MyFacebookApp -> Settings -> Basic -> App Domains
现在不用

http://localhost:3000 
要测试你的应用程序,请尝试

http://dev.mydomain.com:3000 
(假设端口3000)


应该有效:)

“不应该包含协议信息”——理解它有什么问题?不知道协议是什么,域名不同于URL…?域名只是
localhost
,其他什么都不知道。通过
localhost
进行测试不是问题,只要不涉及任何要求Facebook实际从您的域中请求数据的内容(例如开放图形对象)–使用它来测试登录等功能非常好,我在开发应用程序时一直使用这种方式。我很久以前就尝试过,但对我来说不起作用:(也许我可以帮你,…你还感兴趣吗?你是在OSX还是Windows上?是的,我感兴趣…我正在使用ubuntu,我已经用127.0.0.1 dev.mydomain.com设置了我的主机文件,我正在从同一个url访问它,该url是dev.mydomain.com。很抱歉,我的回复延迟了…我刚搬家,没有互联网连接。如果你是您可以通过dev.yourdomain.com访问您的本地Web应用程序,现在您必须在facebook应用程序设置页面的“应用程序域”字段中配置该子域。请确保您在该字段中也包含yourdomain.com…您可以发送屏幕截图吗?以便我可以进一步帮助您..您想要哪个屏幕?
http://dev.mydomain.com:3000