Creating Facebook apps for pages

Facebook apps for pages – they are Facebook apps that can be used in Facebook pages in order to customize user experience. They can range from contact forms, galleries, e-shops, slideshows, embedded flash or anything you can think of.

In the past, you can actually create a customized landing page using apps for pages. But at the moment, it seems the new updates made my Facebook on their site is preventing us from doing this. Nevertheless, apps for pages are still very useful and in fairness, the Facebook updates actually made it easier to create these apps.

Create facebook app

To begin, you need to create your app in the developer page.  Creating it is just a matter of following the instructions.

 

Create the app

Enable Page Tab

Once the app is created, you need to enable the “Page Tab” and “Website with Facebook Login” in the integration section. To do this, you need to at least provide a Site URLPage Tab Name, Page Tab URL and a Secure Page Tab URL. The Page Tab URL is the location on where the content of the app will be pulled from. You also need to provide a Secure Page Tab URL – this is where the content is pulled if the user accessing the app is  using https.

Enable page tab in your app

Add the app to your page

Now, we need to make our page use the app. This part is a bit tricky, but I discovered a way to do it. All you need to do is use this link: http://www.facebook.com/dialog/pagetab?app_id=YOUR_APP_ID&next=YOUR_URL

You need to replace YOUR_APP_ID with the app’s ID and YOUR_URL with the app’s site url.

Example is http://www.facebook.com/dialog/pagetab?app_id=400571490005974&next=http://codertalks.com/.

building the URL to add the app to your pageVisiting the link above will take you to a “Add Page Tab” dialog. From here you can then select the pages where you want the app to be used.

Add Page Tab dialog
The app is now added to the pageAt this point you are now ready for coding. You can use Facebook SDKs to access the api to retrieve some data.

I’ll show you a short snippet to display the page’s information using PHP.

 

1
2
3
4
5
6
7
8
9
10
11
12
require '../src/facebook.php';
 
$facebook = new Facebook(array(
  'appId'  => '128476427297713',
  'secret' => 'e53f919119efd37cf2cb9d294e0da582',
));
 
$signedRequest = $facebook->getSignedRequest();
 
$pageInfo = $facebook->api('/'.$signedRequest['page']['id']);
 
print_r($pageInfo);

 

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s