我使用ASP . net和Facebook Connect api。但是当我运行应用程序并按下连接按钮时,它返回到网站,而不是返回到测试本地服务器(http://localhost:xxxx/test.aspx) 那么我如何在本地测试Facebook(即我如何可以改变回调url) ?


当前回答

当你发现的时候就很简单了。

打开“/etc/hosts (unix)”或“c:\ windows \system32\drivers\etc\hosts”

如果你的域名是foo.com,那么添加这一行:

127.0.0.1    local.foo.com

在测试时,在浏览器中打开local.foo.com,它应该可以工作。

其他回答

最后测试201/06/07

只是补充一下@Erdal_G的精彩回答和我的成功经验:

Apparently, HTTPS is needed even in the local environment (I used the library https-localhost). [I don't know if this is mandatory] create a test app from the main app (https://developers.facebook.com/docs/development/build-and-test/test-apps/) Set the redirect OAuth URI to https://localhost:<MY_PORT>/auth/ and update also all other URIs in .../instagram-basic-display/basic-display/ settings accordingly. Finally, don't forget to use the client-id (aka app-id) and app-secret of the test app in the requests, which are different than the parent app

Facebook似乎随机禁用了在你的Facebook应用程序上将localhost设置为域名的能力。我发现最简单的方法是将我的localhost隧道到网络上。这可以免费使用http://progrium.com/localtunnel/或自定义url(更容易,因为你不必每次在facebook改变url) https://showoff.io

当你发现的时候就很简单了。

打开“/etc/hosts (unix)”或“c:\ windows \system32\drivers\etc\hosts”

如果你的域名是foo.com,那么添加这一行:

127.0.0.1    local.foo.com

在测试时,在浏览器中打开local.foo.com,它应该可以工作。

转到画布页.. 在浏览器中查看。复制地址栏文本。 现在去你的facebook应用 点击编辑设置

在网站中,在网站url中粘贴该地址

在facebook整合,再次粘贴该地址在画布url

同样的代码,无论你需要画布url或重定向url..

希望能有所帮助。

你不需要做任何困难的事情!

Facebook→设置→基本设置:在“App”中输入“localhost” 域”字段,然后点击“+添加平台”选择“网站”。 之后,在“站点Url”字段中写入您的本地主机Url(例如:http://localhost:1337/something)。

这将允许你在本地测试你的facebook插件。