7
2012
Creating a Facebook Application: “Hello World!”
Many of us have spent hours playing games like Farmville, Sims, taking quiz like ‘When are you going to marry’, ‘Who will kill you’ etc in Facebook. Ever wondered how they are built? Ever wanted to built something like that? Ever felt like making your own app to amaze your friends? Don’t worry, it isn’t that difficult. In this series, I will talk about building a Facebook Application from scratch and by the end of it, you will be able to write your own customized application.
This will be the first of the many posts of my Building a Facebook Application series. Here you will learn how to write a ‘Hello World!’ Facebook application. So, hang tight and let the journey begin..
Requirements:
- A Facebook account.
- Web Hosting ( Domain + Space ).
- If you are making a Facebook application for just practice purpose you can host the site locally from your computer.
- PHP Skills.
Setting up localhost:
In this “Hello World!” demo, I have set up my Facebook application locally. You can use your own hosting by replacing the URL ( will explain later. )
Point to remember:
- Facebook accepts only HTTP with SSL/TLS protocol (HTTPS) so you should ensure that your localhost supports SSL protocol.
- If you are using your web hosting, then ensure that it supports HTTPS.
Here are some references to set up WAMP/MAMP/LAMP for HTTPS.
Registering Facebook Application:
- Go to https://developers.facebook.com/apps/
- It might ask you for authentication and some security questions. Put in user credentials that will handle the Facebook Application.
- Click on “Create New App” on top right.
- Pick any “App Display Name” and “App Namespace”. Name the application with some relevant name so that it can be recognized later. “App Namespace” is an unique identifier for your application. Its basically https://apps.facebook.com/ { App Namespace } and should be unique from other applications.
- Agree to the Facebook Terms and then Click “Continue”.
- This will create a dashboard for you application.
- You will be given a “App ID” and “App Secret” for your application. You can save it down somewhere but it is not required in this tutorial.
Creating “Hello World!” PHP Page:
Now let us make a simple “Hello World!” php page in your computer.
- Open any text editor and make a file “index.php”.
- Write “Hello World!” program.
<br /><br />&lt;?php<br /><br />echo "Hello World!";<br /><br />?&gt;<br /><br />
- Make a folder “facebook-app-demo” in your localhost folder.
- Save “index.php” to that folder.
Integrate page with Facebook:
- Go to “App on Facebook” tab on the bottom.
- In “Canvas URL”, you need to put the URL from where the content of the application is pulled from. In our case, you need to put the root directory of the index.php i.e. http://localhost.com/facebook-app-demo/. (note: do not add index.php).
- For “Secure Canvas URL”, just replace http by https.
- “Canvas Page” is the name your typed in the “App Namespace”. You can change this by changing the “App Namespace”.
- “Save Changes”.
Done:
Walla.. and you have just made your first Facebook Application. You can check your application at https://apps.facebook.com/ { App Namespace }.
Demo:
The demo of this application can be found at https://apps.facebook.com/my-first-app-demo.
Next Up:
This is an absolute basic “Hello World!” Facebook application. I just wanted to give you all the feel of how to make your first Facebook Application and how it works. In the coming posts, I will talk about Facebook Authentication, More advanced application that uses the Open Graph, Extracting user’s data, Connecting with other APIs (Google) etc..
Stay with me for more.
Subscribe to fortystones.
Follow @fortystones on Twitter.
Get updated from our Facebook Fanpage.
Related Posts
4 Comments + Add Comment
Leave a comment
Fortystones Lab Projects
Categories
- Articles (43)
- Idea (2)
- Review (5)
- Social Media (29)
- Trending Topics (13)
- Collection (29)
- How To (27)
- Linux (28)
- News (15)
- PHP (6)
- Project (2)
- Tutorials (36)
- Java (4)
- Programming (10)
- Wordpress (7)
Popular Posts
- 40 Basic Linux Command-line Tips and Tricks
- Tips and Tricks for Facebook Chat (Save History/ Video Chat/ Send Files)
- 40 Linux Shell Commands for Beginners
- Creating a Simple GUI for Absolute Beginners (Java Tutorials)
- Online Coding Zones for Programmers
- Special: Facebook Smiley, Special Text Symbols and ASCII Arts
- The First on the World Wide Web

An article by











thanks,it was helpful
Hey, I’ve had a look through your tutorial and I’ve done everything you’ve suggested and it does not work, neither does your link to your demo.
The code got jumbled up (wordpress issue) and I believe that was the reason. You can try again and let me know which step is giving your problem.
Good starter tutorial, thanks a lot. Looking forward to seeing the rest.