如何使用本地主机而开发的Facebook网页图形? [英] how can i use localhost while developing facebook graph website?

查看:198
本文介绍了如何使用本地主机而开发的Facebook网页图形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用本地主机开发使用图形API网站Facebook应用程序。
我在asp.net C#的工作

i want to use localhost for developing website facebook application using the graph api. i working in asp.net c#

在Facebook上的previous API,我是安倍晋三写的
的http://本地主机:4300 / 在应用程序设置的连接网址

in the previous api of facebook i was abe to write the http://localhost:4300/ in the connect url at the application settings.

现在dosent工作。
它不断告诉我
与应用程序的名称出现错误。请稍后再试。

now it dosent work. it keeps telling me An error occurred with application name. Please try again later.

有人建议吗?

**如果我上传的网站,使用本网站coonect URL,它工作。

** if i upload the website, and use the website coonect url, it is working.

推荐答案

Facebook并不在乎什么实际IP地址的服务器位于 - 但它会检查引用页的域名相同的域名你与Facebook注册。诀窍得到它在开发过程中的工作是要找到一种方法,使用的域名,即使你只是努力在本地计算机上进行开发。

Facebook doesn't care what actual IP address your server is located at - but it will check that the domain name of the referring page is the same as the domain you registered with facebook. The trick to getting it to work during development is to find a way to use your domain name even when you're just working on your local machine for development.

如果你有你的DNS记录的完全控制权,你可以添加主机记录(如test.yourdomain.com'),它无论是在开发机器的真实IP地址,点(如果它是一个静态IP),或者干脆为127.0.0.1

If you have full control of your DNS records you could add a host record (eg 'test.yourdomain.com' ) which either points at the real IP address of your development machine (if it's a static ip), or simply to 127.0.0.1

如果您没有访问您的DNS,然后在开发过程中来解决这个问题最简单的方法是简单地增加(在OSX和其他大多数UNIX机器/ etc / hosts文件),您的计算机的主机文件中的条目指向域你的Facebook注册到本地主机。所以你添加一行:

If you don't have access to your DNS then the easiest way to get around this during development is to simply add an entry to your computer's hosts file ('/etc/hosts' on OSX and most other unix machines) pointing the domain you registered at facebook to your local host machine. so you'd add a line like this :

127.0.0.0 test.yourdomain.com

到您的主机文件的末尾。这意味着,如果你现在在Web浏览器中输入test.yourdomain.com这将解决你的本地计算机上。

to the end of your hosts file. That means that if you now enter test.yourdomain.com in your web browser it will resolve to your local machine.

现在 - 在Facebook的应用程序设置的网站部分中,确保您已将域名设置的网站域名部分 - 这将意味着Facebook将接受来自任何子来请求您的域名 - 换句话说,它将接受来自www.yourdomain.com(生产服务器)的请求和test.yourdomain.com(本地开发机)

Now - in the "web site" section of your application setup in Facebook make sure you have added your domain name to the "site domain" section of the setting - this will mean that facebook will accept requests coming from any subdomain of your domain - in other words it will accept requests from both "www.yourdomain.com" (your production server) and "test.yourdomain.com" (your local development machine).

现在你应该能够使用浏览器中的test.yourdomain.comURL在本地计算机上进行开发,而不是'localhost'的,一切都应该工作。

Now you should just be able to develop on your local machine using the "test.yourdomain.com" url in your browser rather than 'localhost' and everything should work.

OH - 一件事 - Facebook的重定向URI也需要有,如果你的开发服务器不在端口80上运行的端口号,但​​它包含该端口号相匹配的域名网址时(坦白说,我认为这是一个在Facebook的API的错误)。这意味着,如果你的开发服务器(例如)端口8080上运行,那么你需要添加:8080到主机名的重定向的URI,但如果你的作品服务器的是在端口80,那么你的不该把80中的重定向URI,否则当人们明确地包含在URL中他们用看的端口号就只会工作,你的页面(不太可能在生产服务器)。这一切都说明在实践中,你只是必须有一个条件,使生成Facebook验证网址时,你只包括端口号,如果不是80端口。

OH - one more thing - the facebook redirect uri will also need to have a port number if your development server isn't running on port 80, but it includes this port number when matching the domain url (frankly i consider this a bug in the facebook APIs). This means that if your development server is (for instance) running on port 8080 then you'll need to add ':8080' to the end of the hostname in the redirect URI, but if your productions server is running on port 80 then you shouldn't put ":80" in the redirect uri because otherwise it'll only work when people have explicitly included the port number in the URL they used to look at your page (unlikely in a production server). What this all means in practice is that you just have to have a conditional so that when generating the facebook authentication URL you only include the port number if it's not port 80.

这篇关于如何使用本地主机而开发的Facebook网页图形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆