Thursday 21 February 2013

Running Facebook apps from localhost

It is possible to develop facebook apps in your localhost be it xampp in windows or LAMP in linux.

Lets make a hello world facebook app  here.

Firstly download a php sdk from here .This allows you to use loads of functions which you needn't worry about defining !!

Paste this in your server (directory) /var/www in LAMP or htdocs in xampp

Now you need to register as a developer and also provide details of your app in facebook , so login to your facebook account and register as developer (look here)


Once you are registered as a developer , go here


Click on create new app, and provide the name of your app, (it has to be unique!)

Then click on continue if your app name is accepted, else try with another name.
After the security check , it allows you to edit the app settings.

 The difference between 'App on facebook' and 'website with facebook login' is that when you select app on facebook , The app runs in a canvas page in facebook itself unlike the other case wherin you login via your facebook account in some other website.

Here inside your /var/www or htdocs you need to create a directory_name folder and paste your codes (.php , .html etc) inside it.

I use something like http://localhost/face/app_name/

'app_name' is a folder inside 'face' , this allows you to have multiple app_name inside face.


Now copy this and save as appname.php inside your directory specified in the Canvas url of facebook app.

The php codes needs you to mention appid ,secret and path to facebook.php (from downloaded sdk)

Run the app in a browser , http://localhost/face/app_name/appname.php.

If it is running you should be able to see your profile pic and other information.


PS:

While developing apps you may need to get permissions on certain user data , for that go to permissions in app settings page.


Enter details in User & Friend Permissions: or  Extended Permissions:


To test these go here



In case you need to install server or create localhost go through this


After these steps if still , the app doesn't  run , check link