How to make Facebook Application
This is probably the most basic app you will ever make, this is a good place to start if you are new to making apps.
You will need to download the PHP client libraries from Facebook, this should consist of:
/facebook.php
/facebook_desktop.php
/facebookapi_php5_restlib.php
/jsonwrapper/jsonwrapper.php
/jsonwrapper/jsonwrapper_inner.php
/jsonwrapper/JSON/JSON.php
/jsonwrapper/JSON/LICENSE
In this example I have placed these is a folder called "client" this will keep everything tidy and seperate from the files in the root.
Next thing you need to do is:
- Visit the Facebook developers page
- You will see a button on the top right hand side saying "Set Up New Application" Click this button.
- Enter your desired name for the application and accept the terms and conditions.
- Application Name
- Application ID
- API Key
- Secret
Now for the script, this is pretty self explanatory, all you need to do is use the essential information (API key and secret) to fill in the variables on this script then upload it to your server where the application will be hosted.
<?php //add your api key here $api_key = ''; //add your secret here $secret = ''; //include facebook.php from the PHP client libraries folder include_once 'client/facebook.php'; //initiate the class $facebook = new Facebook($api_key, $secret); //require the user to login $user = $facebook->require_login(); /*----- All of the above is required-----*/ //welcome message echo "Hi "; ?> <fb:name firstnameonly="true" uid="loggedinuser" useyou="false"></fb:name> <?php echo " your basic app is working!"; ?>
Now this is completed and uploaded you need to go back to Facebook and click on the "canvas" tab on the right, you will now see a section that says "required URLs". You now need to choose a Facebook url.
Then you need to enter the url to the page above that you have uploaded to your server.
You can now test your first Facebook application!
No related posts.


November 16th, 2009 - 18:14
I will be adding more tutorials very soon on how to add more functionality to the application and include how to use PHP with FBML .