Tutorial: Add an iFrame Application to your Facebook Fan Page – Fall 2011

IMPORTANT: Facebook announced that as of February 1, 2012 they are removing App Profile Pages, and the new way is pretty great. Read our article on the App Profile Pages being removed.

Updated Tutorial: Fall 2011

Facebook has been very busy updating how things are done, and one of the changes is how you create an iFrame application tab.

Although the concept is pretty much the same, the interface for creating a Facebook iFrame tab app has changed. This tutorial updates a tutorial we did on this subject earlier this year.

Related Tutorial: Add the Reveal Fan-gating Feature to your iFrame Page Tab

What is an iFrame application?

An iFrame application you allows you to embed an external Web page in your custom Facebook Page tab. Your “index” or “canvas” page is actually hosted on a non-Facebook server and is surrounded by Facebook “chrome” (the Facebook elements on the page).

Because this iframed page isn’t hosted on Facebook, it can use standard HTML, CSS, and JavaScript like any other Web page does. Interactions with Facebook content are done using the Facebook Software Development Kits (SDKs) and XFBML tags. (For this tutorial, the Facebook SDK is not required.)

The downside of this approach is that you need to be familiar with those technologies and you will need a Web-accessible server where you upload the files for your application page. Or you can add an iFrame-creation application to your page, such as TabPress, freeing you from having to create a Facebook application but more restrictive in that you can’t control the icon that appears next to the tab name in the left navigation.

Setting up your server

Facebook’s HTTPS / Secure Hosting Requirement
The first thing to know is that wherever you host the index page of your Facebook iFrame application, the server will have to be secure, i.e., have an SSL Security Certificate for the domain under which it’s hosted.

If your index page is not hosted on an SSL secure URL, or you don’t specify a Secure URL in your app settings, your tab will not display for those using Facebook under Secure Browsing. Instead, the user will see:

Non-secure page Facebook security error HTTPS

Read our article on Facebook Page Tabs and HTTPS.

The other assets called into your page (images, JavaScript, CSS, video, etc.) will also have to be hosted under HTTPS. We recommend Amazon S3 hosting for this, and this is also addressed in our HTTPS article.

Create your iFrame application

On your secure Web server, create a directory for your iFrame application. In this example, on our server we create a new directory called “facebook” and then a subdirectory called “mytestapp”. The file path will look something like this in your FTP program:

You will want to put all of your files (HTML, CSS, Javascript, PHP, etc) in the “mytestapp” folder or its subdirectories. If you don’t know how to do this, read this FTP tutorial.)

Your HTML file

Remember, in your HTML file you can utilize CSS — and inlining styles with the <style> … </style> tags works fine with iFramed HTML files — and JavaScript (Do not use FBML or FBJS!).

You’ll want to set the main container DIV for your content to 520 pixels wide. Here’s a very stripped-down example of your HTML file:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<style type="text/css">
body {
width:520px;
margin:0; padding:0; border:0;
}
</style>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
</head>
<body>
<div id="container">
<p>This is some HTML content</p>
</div>
</body>
</html>

In the above example, I include both the code for an external stylesheet called with the <link /> tag, as well as inlined styles called with the <style> … </style> tags, in case you want to do it that way. Either should work fine.

Installing the Facebook Developer Application

The first step in creating an application in Facebok is to install the Facebook Developer application.

To do that, log in to Facebook and then visit the URL http://facebook.com/developers.

If this is the first time you’ve installed the Developer Application, you will see the Request for Permission dialog show below:

Click the Allow button to proceed.

Creating your iFrame application

Now that you have the Developer App installed, click on the Create New App button.

Facebook Create New App

Give your application an “App Display Name” (the name displayed to users) and a “Namespace” (for use with Open Graph — 8-character minimum; alpha, dashes and underscores only — keep trying until you get a Namespace that hasn’t been used). Then tick the “I agree to Facebook Platform Policies” box; then click the Continue button.

Facebook iFrame App - New App Dialog

On the next screen, enter the security phrase and then click Submit.

There are a lot of options you can tweak related to your application. In this post, we are going to focus on the basics needed to get your iFrame tab application up and running.

The Settings Tab

This is where you do the basic set up for your app.

iFrame Page Tab App - Settings Tab

First, at the top, you’ll see the App ID and App Secret values. Most frequently you’ll be using your App ID to integrate with Facebook.

Second, notice the “edit icon” below the App Secret. This is the icon that will appear to the left of your tab’s name in your page navigation, so make it eye catching and make the dimensions 16 x 16 pixels. If you don’t create your own icon, your tab will have a generic Facebook-tab icon: Generic Facebook Tab Icon

Basic info:

  • App Display Name: Make this the same as the original value you provided;
  • App Namespace: Make this the same as the original value you provided;
  • Contact Email: Where you want Facebook to send emails regarding your app;
  • App Domain: just put “mydomain.com” where “mydomain.com” is your secure hosting server;
  • Category: Select a category from the pulldown list.

Cloud Services
Since Facebook instituted their HTTPS requirement for all applications, they started offering cloud hosting solutions for those who find setting up a hosting account and secure server too much bother, expense or both. But click the Learn More if you’re interested.

Select how your app integrates with Facebook

This is where you select the type of application you’re creating and how it integrates with Facebook.

Facebook iFrame App - Integration

An explaination of the Facebook-integration values

For the purposes of this tutorial, you will select “Page Tab” from the various integration options. It’s the last one listed but once you’ve saved your changes it will be listed first (as in the above example).

  • Page Tab Name: The displayed name of the tab in the Page navigation;
  • Page Tab URL: The unsecure URL (HTTP) of your index page — if the index page is named either “index.html” or “index.php” you can just put the directory with a trailing forward slash (as in my example above); OR you can specify a file name in the directory, eg myapp.html or myapp.php;
  • Secure Page Tab URL: Same as the “Page Tab URL” but with HTTPS instead of HTTP;
  • Page Tab Edit URL: You can create any URL at your domain here and then set up that URL to redirect to the Edit Page for the Facebook tab. This is commonly done using a 301 or 302 Redirect. I’m not covering 301/302 redirects in this tutorial;

If you intend to use calls to the Facebook JavaScript SDK on your tab – Add “App on Facebook” values

If you want to use the Facebook JavaScript SDK in your Page Tab — for example, our Share Button for Page Tabs — you will also need to select the “App on Facebook” integration, and add the same URL values as for “Page Tab”:

Facebook iFrame App - Page Tab and App

NOTE: The “App on Facebook” URL MUST be a directory, not a specific file:

http://www.myDomain.com/facebook/mytestapp/

NOT

http://www.myDomain.com/facebook/mytestapp/mycanvaspage.php

So if you need to specify an “App on Facebook” URL, you’ll need to use “index.html”, “index.htm” or “index.php” for the file name of your canvas page.

The “Canvas Page” value is autofilled by Facebook, with your Namespace value.

Click “Save Changes” and you’re done!

Installing your iFrame application on your Fan Page

UPDATE – December 9, 2011: Facebook is in the process of removing the App Profile Page completely, and has added new ways to add your App to your Fan Page. Read my article on Facebook’s removal of the App Profile Page.

If your App is only to add a Page Tab to your Facebook Page, and not an App that you want to make available to multiple pages, you can simply navigate to this URL in your browser:

https://www.facebook.com/dialog/pagetab?app_id=YOUR_APP_ID&next=YOUR_URL

Replace “YOUR_APP_ID” with your App ID and “YOUR_URL” with your App’s Canvas URL, both of which values are available in your app settings.

You’ll see a page similar to this the one below when you navigate to that URL:

Add App to Page

After selecting the Page from the pulldown menu and clicking “Add Page Tab,” your iFrame app should now appear on your Fan Page. If you don’t see it there right away, you may need to adjust your Page settings. From your Fan Page, click on the “Edit Page” button in the top-right corner of your page. Then click on “Apps” and find the application that you just added. Click on the “Edit Settings” and you’ll get this popup dialog:

Edit Facebook App Settings

  • Tab: If it says “Available (add)”, click “add” to add it to your navigation; if it says “Added (remove)”, you’re set;
  • Custom Tab Name: You can override the default tab name by entering a new name in this field, up to 32 characters, and then clicking “Save”.

Click “Okay” to save your changes.

Troubleshooting

Based on feedback to this post, we are starting to compile some iFrame App Troubleshooting Tips. We will update this section as new questions some up.

Check your URLs!

Make sure that the URL you set for your iFrame is correct. Try accessing it directly, via your browser, instead of via your Page tab. Bad URL addresses are the most common problem. If the URL to the Web page or image you want in your iFrame Page tab is incorrect, obviously the tab won’t work.

You can also test the validity of your URL by right-clicking the area where your iFramed content should be and then select “This Frame: Open Frame in new window” or something similar (each browser presents this option a little differently).

Make sure you have specified an HTTPS / Secure URL for your Page Tab application. If you don’t, your tab won’t load for people using Facebook with Secure Browsing activated.

If you can’t add your Facebook Page Tab application to a Page

People often report this problem, and the cause will likely be one of the following:

  • You’ve already added the App to your Page: Click the “Edit page” button at the top-right of your Page; then click “Apps” in the left column of the admin area; look for your Page Tab app; click “Edit settings” and make sure that in the popup dialog it says “Added (remove” and NOT “Available (add)”;
  • You’re not an admin of the Page to which you want to add the App;
  • Under the App’s “Settings > Advanced” area, you have set “Authentication > Sandbox Mode” to “enabled”; this restricts the ability to add the App to a Page to only the App’s developers;
  • It’s a Facebook bug/glitch: Yes, this could be the cause.

Error messages from your server (error 405 – HTTP verb or similar)

If your server returns an error when Facebook tries to load the HTML page into the iFrame, you may need to change the file extension from .html to .php or .aspx (depending on the server platform you are using). When Facebook loads the iFrame, they do a POST to the index page in order to pass some data to your application and it looks like some servers are set up to not allow a POST to a file with the .html extension. We will be taking a look at how to access the data that Facebook passes in the next tutorial, but I wanted to mention this now since it caused issues for some people.

API Error Code: 191 Popup Dialog

If you get the “API Error Code: 191″ popup dialog error:
Facebook API Error Code 191 - Dialog Popup

when using an embedded Share Button or other feature that requires the Facebook JavaScript SDK, it’s may be because you haven’t specified the “App on Facebook” URLs. See above for details.

Scroll Bars – Getting rid of them!

If your iFrame content causes a horizontal scroll bar to appear, something is causing the width to exceed 520 pixels, which is the maximum that Facebook allows. Read our tutorial on troubleshooting and eliminating the iFrame scrollbars.

We recommend adding some CSS (either inline as shown below or in your separate CSS file) to remove margin, padding, and border from elements by default. Many browsers add spacing around certain elements by default which can cause the scrollbars to appear unexpectedly.

<style type="text/css">
body {
width:520px;
margin:0; padding:0; border:0;
}
</style>

Next Steps

Up next: Creating a Reveal Tab on an Facebook iFrame application using the PHP SDK

We would love to hear what you would like to see in this series — If you would like to know how to do something specific using iFrame applications, just note it in the comments and we will see what we can do.

Additional Resources

Technorati Tags: , , ,

  • http://www.facebook.com/gvharvey Guy Harvey

    Hi Tim. Great info. I’m pretty sure last week I found a link  here that allows you to enter your FaceBook apps info & ad it to your Apps so you can make it a live page people can see while FaceBook is rolling out the option. You have so much conten here I can’t find it again. do you happen to know of the link I’m asking about? Thanks in advance. Guy

  • Bianca Cloutier

    I love your resources! I have a quick question – if we had land page apps up and running before the change happened in December, do we need to make any changes before Feb 1st or will these continue to run going forward on the fanpages they’ve been added to? Thanks!

    • http://www.hyperarts.com/blog/ Tim Ware

      The removal of App Profile Pages won’t have any effect on existing implementations of the App. It just affects how users can add your app to their pages after February 1.

      • Bianca Cloutier

        Very cool! Thanks. And last question, I was wondering if you knew roughly the percentage of users out there that have their privacy settings set so that they would be unable to view an app landing page? This is the only challenge I’ve run into with the apps so I just want to be mindful of the number of folks this may impact. :)

        • http://www.hyperarts.com/blog/ Tim Ware

          If you mean how many users are opting for “secure browsing” and thus your tabs can’t be viewed by them, then I’d expect a pretty big number, although I don’t know the exact number or even a range.
          But not hosting your iFrame content securely will definitely cost you in views of your tab, so I strongly recommend you do secure hosting.

        • Bianca Cloutier

          Hmm… we’re using HTTPS in terms of URL for the canvas. Does that count as “secure browsing” or is there something else we need to do?

        • http://www.hyperarts.com/blog/ Tim Ware

          If HTTPS works on your canvas page / index page URL, then you’re good with secure browsing.

  • http://mrtunes.ca/blog Mr. Tunes

    hey tim, i am completely lost! i’ve made the tab/app in the developers area, and i’ve even now had to make a “page” for this tab (how silly is that?), and now i can’t find the “add this app to my page” link that used to be on these pages. they have made this process so convoluted for simple welcome tabs. 

  • http://twitter.com/DanniBarrett Danielle Barrett

    Hi,
    Thanks for the tutorial.
    Quick question I am using a stand alone business page that is not linked to a personal Facebook profile. As such I am having problems using TabPress – it will not load when I click on it in the page editing area – is this because being a Business profile and page it is limited?

    Thanks
    Danielle

    • http://www.hyperarts.com/blog/ Tim Ware

      Business Pages are much more limited in what you can do than Pages linked to Personal Profiles.
      For one thing, business accounts can’t add custom tabs or other apps. From the Facebook Help Center:
      “You will not, however, be able to view the profile information of any other users on the site, or add any other applications to your account. Your account will not be visible in search and other users on the site will not be able to find you and add you as a friend.”

  • http://www.facebook.com/pgoochie Paul Louis Goochie

    Please please please help. Facebook appear to of changed the backend again. I’m trying to create my own iFrames app and not use pre-existing static html iframes apps (as they have limited functionality). I’m trying to create multiple tabs for my facebook page. I’ve followed every example on the internet and none seem to resemble what i’m seeing. You’re posts are super informative but i just can’t seem to work out how to create multiple iframes tabs on my page. Any idea on how to do this? or wether we have to wait until feb when they change it all again? so confused… please help :)

    • http://www.hyperarts.com/blog/ Tim Ware

      Apps like “Static HTML” and TabPress can be used to add a custom Page Tab to your Page.
      If you create your own Facebook App for a Page Tab, then you can create as many of them as you wish. But you can only add an app to a Page once.
      To create “multiple iframes tabs” you’d have to create a separate app for each tab.

  • http://www.hyperarts.com/blog/ Tim Ware

    Hi Markus. Thanks for pointing out that incosistency in my post! “mynewtab” should have been “mytestapp”. I’ve corrected this error.
    As for the Page Tab URL, if it’s called “index.html” or “index.php” you can just have the directory with a trailing forward slash, as in my example. Or you can specify a specific file name, eg app1.html OR app1.php, app2.html…. etc.
    I have also clarified this in the article. Thanks again for the heads up!

  • http://lars.arholm.net LBA1403

    Hi Tim, would really appreciate if you answered my question.

    I’ve tried lots of the big iframe-apps (tabpress for instance) on facebook, but no matter which one I use CSS-codes doesn’t work, which is really frustrating. HTML and javascript works, but not CSS. Do you think that if I made the effort to create my own ifram application, which I imagine to be kind of a big job, CSS would work? 

    • http://www.hyperarts.com/blog/ Tim Ware

      If your CSS isn’t working in TabPress or other iFrame Page Tab apps, then it’s your CSS that’s the problem, not those apps. You should double check your CSS syntax and make sure it’s error free.

  • http://www.hyperarts.com/blog/ Tim Ware

    Once you’ve added the Page Tab App to your Page, it’s done. You only need to migrate your App Profile Page to a Facebook Page if you feel you need a Page for your App.
    As this article says, for Page Tab Apps that are added to only one Page, you don’t need and probably don’t want a Page for the App.

  • http://www.facebook.com/luke.n.smith1 Luke Naples Smith

    Tim,
    Facebook shows the following Dialog:

    This application does not support integration with your profile.

    Any answer?

    • http://www.hyperarts.com/blog/ Tim Ware

      When do you get that message, what kind of app, and what are you trying to add it to?

  • http://pulse.yahoo.com/_BMQFEB6HG3FBPPKCRNZCDOSNIQ Ben

    Great.. this is very helpful as I search around for how to install the page tab for long time & just realised that FB has to remove the App profile page… 

  • http://www.facebook.com/people/WorkhorseDigital-SocialManager/100001837010706 WorkhorseDigital SocialManager

    I’ve created a test html page “test” on a secure server. 
    (https://www.0808project.com/bettySport/facebook/tab/index.html)

    Created the facebook app, added it to my page, and when you click the tab it doesn’t load. If I go to edit my page and go to the app and click on “go to app” it loads fine. I’ve built many apps before and never had this problem. Any ideas would be greatly appreciated.ThanksWesley

    • http://www.hyperarts.com/blog/ Tim Ware

      What is the URL of your tab on Facebook? It must be something in your app settings, and Facebook has added a number of variables and options in recent months. I’d advise closely examining your app settings.

  • http://www.hyperarts.com/blog/ Tim Ware

    Is your app a Page Tab or a Canvas App? If it’s a Page Tab, it shouldn’t exceed 520px in width. If it’s a Canvas App (with a URL like: apps.facebook.com/your-app-name), then you have a max of 760px in width.
    If your App is a Page Tab, you can also ignore: Settings > Advanced > Canvas Settings.
    Those settings are only if you’re developin a Canvas App.

  • Anonymous

    when ever I ty to set up a server for my app, I get the error messages ”
    Error
    You have specified an App Domain but have not specified a Site URL or a Mobile Web ”

    Where do I set up a Site URL?

  • http://www.hyperarts.com/blog/ Tim Ware

    You can ONLY set a default landing tab for non-fans. An admin of the Page or anyone who’s already Liked your Page, will default to the Wall, and this can’t be changed.
    So in the “Edit Page” area you can set the default tab, but only for non-fans.

  • http://www.facebook.com/profile.php?id=1843038559 Markus Wilhelm

    Hi Tim, a nother question from me to your GREAT tutorial :)

    is it possible to preset all of this and put it on invisible?
    so i can put it visible on a later date?

    big thanks!

    • http://www.hyperarts.com/blog/ Tim Ware

      Just add the App to your Page. In: Edit Page > Apps > Your App] > Edit Settings

      If, next to “Tab:”, it has “Added (remove)”, just click “remove”.

      When you’re ready to show to tab just do the above, but click “Add”.

  • Anonymous

    Hi,

    I’m getting this message in a red box when I try  to save the ‘Basic’ page:

    “You have specified an App Domain but have not specified a Site URL or a Mobile Web URLwww.thesatmathprep.com must be derived from your Site URL or your Mobile Web URL.”

    In Basic Info then App Domain, I have typed in ‘thesatmathprep.com’ (the address of my website).

    Can somebody inform me of what I am doing wrong, please?

    • http://twitter.com/i2ivision i2i Vision

      Under “Select how your app integrates with Facebook” section, you have to click the bar which says “Website” with the checkmark next to it.  That will make the bar fold open and you’ll see “Site URL”. Then enter your full site URL there.  It took me a little while to find it, too!

  • http://www.facebook.com/directordlwatson D.L. Watson

    “https://www.facebook.com/dialog/pagetab?app_id=YOUR_APP_ID&next=YOUR_URL” Where or what the heck is the “YOUR_URL”?

    • http://www.hyperarts.com/blog/ Tim Ware

      As the tutorial says, it’s the URL of your app’s canvas or index page. Or try http://www. facebook. com/

  • http://www.hyperarts.com/blog/ Tim Ware

    Your URL doesn’t go to a tab.

  • Jan Brtka

    Thank you very much! This is one of the best tutorials I have read BY FAR! :) everything went down smoothly. But I couldn’t figure out how to add multiple tabs on my funpage.. Thx once more!

    • http://www.hyperarts.com/blog/ Tim Ware

      You have to create a separate app for each tab you want to add to your FAN page

  • Jodine Hansen

    Hi there,
    Is is possible, when displaying a webpage in a tab, to add at ‘click here to open in a new window’ button?
    Thanks.

    • http://www.hyperarts.com/blog/ Tim Ware

      Sure. Just add target=”_blank” to the <a href /> link.

  • http://twitter.com/helios_design Helios Design

    This is so brilliant and helpful. Had problems adding app to page and this worked! Thank you for sharing.

  • http://twitter.com/newsfeast NewsFeast

    Hello Tim!
    I want to ask if it possible to re-direct users to my funpage-wall when someone is on my landing tab and press the like button. I am asking because when users like my page, the button disappears but tab does not change! Any ideas?
    PS: Very helpfull article!

  • http://www.hyperarts.com/blog/ Tim Ware

    Your URL should have this format:
    https://www.facebook.com/dialog/pagetab?app_id=YOUR_APP_ID&next=YOUR_URL
    Your URL omits the “&next” after the App ID and before the URL.

    But your URL apparently isn’t the same subdomain as the index/canvas page for your app and it has to be for this to work.
    Try using: http://www.facebook.com instead. I tested your URL with the above changes and it works fine.

    • http://www.facebook.com/salvatore.escalante Salvatore Escalante

      Thank you so much Mr Ware! Now it is working! :)
      But I got another problem! Hope you can help me with this one too
      I have created some others facebook app and they work fine, I always use the same codes, same process and all the apps work in any browser, but with this one I cant make it to work with Chrome, its works in Firefox, safari but not in Chrome.
      Any idea what could be the problem with?

      And again thank you for your time and your help
      btw Greetings from El Salvador

      • http://www.hyperarts.com/blog/ Tim Ware

        You’re on your own with the Chrome issue, Salvatore. I’m afraid I can’t help you there. But I’m pleased that I helped you sort out the previous problem!

  • http://www.facebook.com/shakespeare.puccini.guerrero.pinza Shakespeare Puccini Guerrero

    I would like to develop a vote entry application using PHP but I am just learning it so actually I am completely lost. I want to build an application like this 
    http://www.facebook.com/Dr.Luis.Bitar?sk=app_134514206651551
    Thanks in advance

    • http://www.hyperarts.com/blog/ Tim Ware

      Best of luck, Shakespeare.

  • http://www.hyperarts.com/blog/ Tim Ware

    Good question, Chloe!

    Facebook understands that the purpose of your Welcome tab is to — or *should* be — to entice users to Like your page. Once that is accomplished, then Facebook prefers that the default be the Wall as that’s where everything really “happens” … all the engagement etc.
    So Facebook allows you to set your Welcome tab as the default only for those who’ve not yet Liked your page.
    You refer to the “Static HTML” app, but you must be referring to “Static FBML”, Facebook’s custom-tab app that can no longer be added to pages. The Static HTML app isn’t provided by Facebook.
    Whether or not you use an app like Static HTML to create your Welcome tab, or just code it yourself, you still can make that tab the default for those who’ve not yet Liked your Page.

  • http://www.hyperarts.com/blog/ Tim Ware

    The “App on Facebook” URL can only be the index page of a directory, either just the directory with a trailing forward slash, or index.php, index.html, index.htm, index.asp, etc.
    The Page Tab URL can be a specific web page such as your examples (enews.php, etc.).

  • Renata Fortes

    Hi, this is a great tutorial. I still can’t see my tab when the user doesn’t like my page. I haven’t developed any fan gate i just want to both who likes and who doesn’t see the same page but it is not working, this is my page: https://www.facebook.com/?ref=logo#!/WeAreBuiltToLast?sk=app_242901325795370 thanks

    • http://www.hyperarts.com/blog/ Tim Ware

      I see your tab just fine, Renata.

  • Ian Simmons

    Very good tutorial! I was confused by the YOUR_URL part at first, trying to figure out what url it wanted but once I got it figured out it wanted the url of the app on my server everything works great. Moving on to the article on the reveal page setup.

    Thank you very much!