Facebook is the fastest growing social networking application that currently has more than 350 million active users. One of it’s key features is Facebook Platform, that enable us to build applications on Facebook. Currently there are a lot of Facebook applications built by developers around the world such as game, which is the most popular application on Facebook.
This tutorial will guide you through the creation of a Facebook application using Facebook PHP API that will display Hello World text, called Hola Mundo. Before we begin to create Facebook application, there are a few things that you have to know:
If you have meet the requirements above, you are ready to get started building Facebook application through this tutorial.
A. Setting Up Your Application

Facebook Developers Area

Create New Application

Setup Application

Canvas Settings
B. Configure Application on Your Host
After configuring your application on Facebook, it’s time to do a little bit coding and some server administration tasks.
<?php
include_once 'facebook.php';
$apikey = 'typeyourapikeyhere';
$secretkey = 'typeyoursecretkeyhere';
$fbObj = new Facebook($apikey, $secretkey);
$myuid = $fbObj->require_login();
$fbml = "<h2>Hello world, my name is <fb:name uid=\"$myuid\" useyou=\"false\" />,"
. "welcome to my first facebook application!</h2>";
echo $fbml;
?>
Simple right ? Facebook has made it simple using FBML, all you have to do is apply the predifined tags on your code. You can read the complete explanation about FBML on Facebook Developers Wiki page here .
line 2: include the facebook main library file
line 4&5: define your api key and secret key
line 7: create an instance of Facebook client class
line 8: get your facebook user id (uid), the require_login method is used to force user to logged into Facebook before using the application. If they are not logged in, Facebook will redirect them to Facebook login page first and then brings them to your application page after they logged in.
line 9: your page content’s that display your name using FBML Fb:name tag.
Now your application is complete and ready to be accessed by anyone in the world. Type your Canvas Page URL on browser and you’ll get Allow Access page which is default for Facebook application for the first time access, click Allow button to access your application.

Allow Access Page

Your Application Page
You can view live example application above here
Related post:
[...] This post was mentioned on Twitter by Lorensius Londa, Lorensius Londa. Lorensius Londa said: Mari belajar bikin apliksi di FB http://bit.ly/7EnHBf via @AddToAny [...]
How To Create a Facebook Application http://bit.ly/AdW6zl
A very simple how to guide for beginners.
[...] This post was Twitted by itaysela [...]
Social comments and analytics for this post…
This post was mentioned on Twitter by lorenslonda: How to Create Facebook Application with PHP for Beginner http://bit.ly/7EnHBf via @AddToAny…
[...] View post: How to Create Facebook Application with PHP for Beginner … [...]
Hi,
Great tutorial, however I did not work for me.
I created a directory in my website http://www.trendspot.ie.
I called it ‘facebook’.
I created the index.php file and dragged it into the my new ‘facebook’ directory along with the the php files in the facebook client library. I did this using FTP.
When I go to preview the app I get this message…
Not Found
The requested URL /facebook/ was not found on this server.
Apache/1.3.37 Server at trendspot.ie Port 80
I don’t know what I’m doing wrong and I hope you could help!
Thanks,
Colin
Hi Colin,
Have you tried to directly access the ‘http://www.trendspot.ie/facebook’ ? was it work ?
hi lorenz
i’m now stuck at the canvas callback url
i understand that i can’t use localhost for my application and neither do i have a webhost. I saw that you use some ip address for the callback url. can you help me with these cuase i think that is my main problem to display my application on facebook..help me please.
thank u so much
As way to perform cross-domain attacks…
In the Facebook force autolike script there are some weak points Facebook engineers can exploit to hunt down script users. In fact, every script leaves behind footprints we can use to track down and find users. Every coder has a certain style when he w…
Very nice tutorial!. Thank you very much.
Hello,
Nice tutorial. Like that. I am facing 1 problem now. Redirection Problem. When I hit the Url of my app then it start infinite redirection url. I think the token is not getting verified. Please let me know how can I resolve this??
Thanks
Rahul Anand
Please reply me on my Email ID.
thanks
Quick question, it looks like I could just add the rest of my php script under the code facebook provides, so in other words if i had a stand alone php script I could easly turn it into a facebook app. I this right what I am understanding?
Novoline Online…
Book of Ra, Sizzling Hot und viele andere bekannte Slots stammen vom Hersteller Novoline, welcher mit den fast gleichnamigen Automaten Novomatic (nee, andersrum) richtig viel Asche verdient….
Title…
This is my Excerpt…
Book of Ra…
Book of Ra ist ein mega-fettes Novoline Spiel welches die Herzen aller echten Zocker bereits heute erobert hat. Es gibt nicht nur das beste Freispiele Feature aller Novogames sondern auch richtig dicke Bonusse welche deine Gewinne…
[...] create a facebook application http://www.londatiga.net/it/how-to-create-facebook-application-with-php-for-beginner/ , you need a real domain for Canvas URL. For that reasons I have faced a real trouble to develop [...]
Hey…This sounds verry good. Amazing Novoline and Book of Ra options. I will try it as sonn as possible..:Thank you sir
Book of Ra, Sizzling Hot und viele andere bekannte Slots stammen vom Hersteller Novoline
Go to http://www.7tech.co.in/php/how-to-create-a-facebook-application-using-php/ to learn more about the facebook application development.
Hello,
I am facing some unique problem in fb app.
Recently we have shifted our fb app to another server
We have installed lamp server on new server and copied all files in that new server, keeping all root directories and folder positions to be same and also changed all pointing to new servers.
But when we tried to open app it is showing us “Failed to load source for: http://xxx.xxx.xx.xxx/xyz/?auth_token=f02eec916d6895d7ff65”
Please help
thanxxx….
Nice post. I found this blog which provides you how to create any type of business application and easily integrate it into your Facebook business page
http://blog.caspio.com/integration/create-a-custom-facebook-application-for-your-business/
great post . Thanks you so much
Bookofradeluxe
June 20, 2011 at 9:46 pm
Book of Ra, Sizzling Hot und viele andere bekannte Slots stammen vom Hersteller Novoline
[...] http://www.londatiga.net/it/how-to-create-facebook-application-with-php-for-beginner/ [...]
Thank you for this guide. We will insert this facebook login on our rating and review site. It works already on our test-site. The only thing we could not manage is to replace the text “login with facebook” with the login button of facebook. Any idea how to solve that problem? Thank you.