Facebook Connect on localhost

Overview

More often than not, you will want to test the Facebook Connect feature on your localhost before deploying it on a live site. Facebook, of course, will not recognize the localhost as a valid web server and probably won't even allow you to create the application that points to localhost. So, are you doomed to try the Facebook Connect only on a server that is publicly available?

No, not at all!

Modifying the Host's File

The first thing you will need to do is to point your domain name to the localhost IP address:

127.0.0.1 mightylocal.dev


This domain name can be set to practically anything you prefer; it can be even dfdgter.khdfslsdfp as long as you're able to remember it.
To make things a bit easier, let's just call our localhost server mightylocal.dev
So, if you're a Windows user, you will need to navigate to C:\windows\system32\drivers\etc\hosts and add the line above to the bottom. For Mac/Linux users, this file is normally located at /etc/hosts, although this can vary with different Linux distributions.

Setup the Facebook App

Create the Facebook App exactly as outlined here; only this time, you will use the mightylocal.dev for your domain name as shown in picture below:<br.>

Mightylocal.png

Final Result

After you have set the Facebook Application and copied the keys into the JomSocial configuration, you must visit your localhost site Frontend by going to this address:

http://mightylocal.dev


or

http://mightylocal.dev/path/to/your/joomla/test/site


Yes, the app will work for all subdomains too.
Now, when you’re on http://mightylocal.dev, try to use Facebook Connect. If everything went okay, you’ll be able to use it.

Mightylocal1.png
Note: Be careful that if if you try to access the localhost on a standard way by just typing localhost or 127.0.0.1 in the address bar, the Facebook Connect will fail. Also, if for whatever reason this trick dont work for you, then please take your time to setup the FBC on some publicly available domain as many factors can affect the fail such are firewalls for example, which are beyond our reach. But be advised that this is tested, and working.

See Also