PHPBuilder - PHP Development on the Facebook Platform: Building Your First App



RSS Twitter
Articles Application Architecture

PHP Development on the Facebook Platform: Building Your First App

by: Sachin Khosla
|
April 19, 2010

So you have been using Facebook for a while now and you're ready to dig down deep into it. That's certainly a good idea, because the Facebook API is very powerful and it allows you to create your own Facebook applications, which you, your friends or everyone else can then consume.
You can use the Facebook applications you build on profile pages, canvas pages, and so on. You can even make money by developing practical applications. So, let's get started with creating your own Facebook application.

What You Need

To create your own Facebook application, you should know how to program in one of the supported languages, such as PHP, Ruby on Rails, or Python. (For this tutorial, I assume that you are good with PHP, and I use Facebook's Status Updater application as an example.) With that knowledge, all you need to do to get started is:
  1. Add Facebook Developer Application to your Facebook account.
  2. Add your first Facebook application.
    1. Then it's your baby!

      Add Facebook Developer Application

      Go to the Facebook Developers page and click "Add developer." This is the central location for all your applications on Facebook. You can request as many as 100 API keys from the applications page, as well as manage and change the settings for all your applications. Now that you have added Facebook Developer Application to your account, let's move on to adding your very first application.

      Adding Your First Facebook Application

      Go back to the Facebook Developers page and click the Set Up New Application button. This will take you to the "Create Application" page, where you are required to provide the name of your application and, as a rule, agree to certain terms and conditions.
      After saving changes to this page, you will be taken to your application's homepage, which serves as your application's edit page. You can change all the settings related to your application here, such as its name, description, icon, logo and much more. You can add more developers if you are going to develop the application in a team.
      On the same page, Facebook provides you with an API Key and a Secret Key, which are the passports for your application to interact with
      Facebook core applications and the outside world. Do not share you secret key with anyone.

      Pre-development Changes

      To start developing your application, you need to make important changes to the following settings:
      • API Key – This unique key helps Facebook identify whatever request(s) you make. Enclose this API key along with all your requests.
      • Secret Key – As mentioned previously, you should keep this key safe and share it with no one, because it is responsible for authenticating your request.
      • Now, click on the Authentication tab, where you need to specify:
      • Post-Authorize Callback URL – When a user authorizes your application and adds it to a Facebook account, then Facebook pings this URL. So, this URL needs to be your site's URL where you application is hosted. This cannot be a URL from Facebook.
      • Post-Authorize Remove URL – When your application is removed by a user, this URL will be pinged along with a post request, which will contain the User_id. This process allows you to log which user has removed your application.
      • Now click on the canvas tab, where you need to specify:
      • Canvas Page URL – Choose a canvas page URL for Facebook, such as http://apps.facebook.com/your-app-name.
      • Canvas Callback URL – This is the muscle of your application. Facebook pulls the content from this URL and displays it on the application's canvas page. The URL can be where you have your application hosted.
      • Render Method – You need to selected this option according to your code. If your code is going to have FBML tags, then you should select "FBML" in this option. Otherwise, leave it default as "iframe" (for this example, you can choose either).
      These settings should be enough to get you started with your first Facebook application. Undoubtedly, you can make many other changes to suit your needs in due course.

      Comment and Contribute

      Your comment has been submitted and is pending approval.

      Author:
      Sachin Khosla

      Comment:



      Comment:

      (Maximum characters: 1200). You have characters left.