How to Create a Facebook App in PHP


Facebook is the most famous social networking website of all time, it has changed the way we interact with people around us. It has become so popular that many of the web developers have tried to integrate facebook into their websites. This can be done by creating a Facebook application.

In this blog, I am going to discuss how Facebook applications are created in PHP.

What is a Facebook App?

Facebook applications are created in PHP. This tutorial will show you how to create your own Facebook application in PHP, the correct way and with a few examples.

Facebook applications are created in PHP and must be hosted on a server with PHP and MySQL installed. All Facebook applications also have an App ID, which is used to identify the application. All requests made to the Graph API must contain this App ID (in addition to any user access tokens that may be required).

The first thing you need to do is create a new Facebook App. This can be done by going to http://www.facebook.com/developers/ and clicking the Set Up New Application button.**

Facebook applications are created in PHP, but use Facebook’s own markup language (FBML) to deliver the interface. FBML is a superset of HTML, with a lot of added functionality specific to Facebook applications. The first thing you have to do when you make a Facebook App is create a Facebook account for your application. The application will be associated with this account and it is also the page that users “become fans” of when they use the app.

The next step is to log into http://developer.facebook.com and create an App at http://www.facebook.com/developers/createapp.php. You can use your existing Facebook account or create another one for this purpose if you wish. When you’ve done this, you’ll be given a unique Application ID number and an API key number. You can see some example PHP files on the developer site, but I prefer my own way of doing things, so here we go:

The first thing I do is create an “index” page that displays the application in its normal mode (or profile box mode), so I create index.php and put the following code into it:

Facebook provides a powerful set of APIs that are used to create Facebook applications in PHP. We will be looking at how to create Facebook applications with PHP in this article and I will be trying to provide a simple introduction to the Facebook APIs.

There are many types of Facebook applications: games, quizzes, content sharing apps, etc. All of these are created by using the Facebook APIs. These APIs help you retrieve data from a user’s profile and also help you post information back to the user’s profile. For example, you can use these APIs to get the details of a user’s friends or post a story on his wall.

The pre-requisite for creating a Facebook app is that you need to have an account with Facebook. If you do not have one, go ahead and create one. Once your account is created and activated, log in to your account and visit the Developer App page at https://developers.facebook.com/apps . Click on Create New App button on the top right corner of this screen and in the ‘Create New App ID’ dialog box that opens, enter an app name and click Continue.

This blog is based on how to create Facebook applications using PHP programming language. I have created a Facebook application using PHP and MySQL. The name of the application is “Know My Friends” which tells you about your friends’ activities on Facebook.

The following are the steps to be followed in order to create a Facebook application:

1. Go to http://www.facebook.com/developers/createapp.php and register as a developer with Facebook by clicking on the Sign Up button.

2. Once you become a registered developer, you can see the ‘Create an App’ page, where you have to fill in all the required fields such as App Name, App Contact Email and Captcha field (to ensure that there are no Bots). Once all fields are filled in, click on ‘Continue’. Now you will be able to see your App ID and Secret key for your application.

3. Click on ‘Set up New Application’ button and this will take you to a new page where you can edit your application settings like name, description, logo and so on. Once it is over then click on ‘Save Changes’.

Facebook, the largest social network of the world, has been an important part of almost every developer’s life. The Facebook API and SDK allow you to tap into all the features for creating a more integrated experience for your users and also make your applications more user-friendly. Creating a Facebook app requires a developer account from developers.facebook.com and knowledge of PHP programming language.

This blog focuses on how to create a Facebook app in PHP with steps that are easy to follow.

1) Create a PHP file named index.php at the root folder of your server along with a blank canvas page named canvas.php in the same folder.

2) Include the PHP SDK in the index.php file by adding the following code:

I am sure you must have seen the new facebook apps that are becoming popular like the “What does your name mean” or “Which Celebrity do you look like?” etc. These apps were created using the Facebook API using different programming languages. This is a step by step guide on how to create your own facebook application using PHP. I’ve tried my best to keep it simple and understandable.

First, you need to create a PHP file that will contain all the functions necessary to make the app work. Let’s call this file “core.php”. The main function that we’ll use to retrieve data from Facebook is cURL, a client URL library which allows you to connect and communicate with many different types of servers with many different types of protocols, so we need to add this function in our core file.


Leave a Reply

Your email address will not be published.