Facebook development in localhost

2019-01-02 19:25发布

Just wanted to know if there is any way I could develop Facebook applications in localhost.

18条回答
旧时光的记忆
2楼-- · 2019-01-02 19:42

There is ! My solution works when you create an app, but you want to use facebook authentification on your website. This solution below is NOT needed when you want to create an app integrated to FB page.

The thing is that you can't put "localhost" as a domain in the facebook configuration page of your app. Security reasons ?

You need to go to your host file, in OSX / Linux etc/hosts and add the following line : 127.0.0.1 dev.yourdomain.com

The domain you put whatever you want. One mistake is to add this line : localhost dev.yourdomain.com (at least on osx snow leopard in doesnt work).

Then you have to clear your dns cache. On OSX : type dscacheutil -flushcache in the terminal. Finally, go back to the online facebook developer website, and in the configuration page of your app, you can add the domain "dev.yourdomain.com".

If you use a program such as Mamp, Easyphp or whatever, make sure the port for Apache is 80.

This solution should work for Windows because it also has a hosts file. Nevertheless, as far as I remember Windows 7 doesnt use this file anymore, but this trick should work if you find a way to force windows to use a hosts file.

查看更多
牵手、夕阳
3楼-- · 2019-01-02 19:43

Facebook no longer allowed a 'localhost' callback URL for FBML Facebook applications

查看更多
人间绝色
4楼-- · 2019-01-02 19:44

With the new development center it is now easier:

1) Leave app domains blank.
2) Click Add Platform
3) Site URL should equal the full path of your local host.
4) Save Changes

查看更多
看淡一切
5楼-- · 2019-01-02 19:46

Try this:

https://ngrok.com/

Its Worked for me...

查看更多
千与千寻千般痛.
6楼-- · 2019-01-02 19:48

Suppose that you have registered your app as:

app.domain.com

You just need to modify the /etc/hosts file by adding

127.0.0.1 dev01.app.domain.com

Then, modify your apache configuration

ServerName dev01.app.domain.com

and restart apache.

You'll need to put your URL in a variable in order to use it as XML parameter on some calls:

<fb:login-button registration-url="http://<?=$URL?>/register" />
查看更多
呛了眼睛熬了心
7楼-- · 2019-01-02 19:48

app domain : localhost

site URL : http://localhost:4440/

worked for me with the new UI.

查看更多
登录 后发表回答