1. #1 by sf - March 9th, 2010 at 11:57

    What if I don’t have an ‘appinclude.php’ file on my server… Where does that come from? Sorry I’m kind of a beginner.

    For my index.php file am I good? I have the following :

    [Code deleted...]

    Thanks for your help!

    • #2 by admin - March 9th, 2010 at 17:18

      As I mentioned, I don’t have time to troubleshoot everyone’s code, particularly their PHP.

      The appinclude.php is a file you must create and have on a server.

    • #3 by Andreas Sefzig - April 6th, 2010 at 11:44

      You will have to create the appinclude.php yourself, it is not a given in any server’s preconfig (or by the sdk I believe you have gotten used to). Use the ‘template’ Tim has provided and fill in the data presented to you by facebooks developer-app. The rest looks fine to me (but I haven’t tried it). Good luck!

  2. #4 by rich - March 10th, 2010 at 13:55

    quicky.. does the app need to be iframe or fbml?

  3. #6 by rich - March 10th, 2010 at 21:59

    got it working, thanks. got a tip to “smartsize” or auto-height the iframe?

  4. #7 by Justin Meighan - March 25th, 2010 at 07:21

    Does the application setting matter? (iframe or fbml)
    From what I gather, when you add an application as a tab, it is rendered as FBML anyway (as I found out the hard way with my iframe app)

    The application tab is really very restrictive, as its more of an application view that a full on application in a tab.

    This is a great post and could provide a workaround to simply pull your app in via the canvas url and have it all sitting pretty in a profile tab.

    Thanks for sharing.

    • #8 by timware - March 25th, 2010 at 07:44

      I’m not sure if you can use iFrames in an FBML canvas page, as opposed to an iFrame canvas page. I know you can in the iFrame canvas page because I did it.

      But, yeah, with the application tab width soon to be reduced to 520px, the canvas page is the way to go, as it’ll still be the 760px width, and allows much more functionality.

      • #9 by Andreas Sefzig - April 6th, 2010 at 12:04

        I believe in terms of usablilty tabs have the valuable advantage to integrate gracefully into the features fanpages are offering, like wall, info, notes; while canvas-pages of apps pop out of the ‘usual’ user-experience facebook-users are used to.

        On a canvas-page, facebook-newbies might not find their way to the rest of your offerings and tend to use the back-button of their browser – these people are lost possibilities… (You could solve this issue by providing links, still people will not find them intuitively.)

        Application tabs can be (almost) as feature-rich as canvas-pages. I would (and do) recommend fanpage-tabs, even when they are smaller, to have all the great content your brand provides showcased just one click away.

      • #10 by Nick - June 24th, 2010 at 12:46

        Just following back up on this, as it looks like this width change should be coming late July (right when my go live is scheduled). If we follow the canvas page method outlined here, are we exempt from the 520px width? I have made my application at 760 and everything is good to go now. The primary route to my application will be from a tab on a brand fan page. It will be viewed under a tab, but your comment above seems to imply it’s not the same type of application. Do I need to reformat everything to 520?

        Perhaps I’m confusing application tabs with fan page tabs? My application has no tabs, just iframed content.

        • #11 by timware - June 24th, 2010 at 20:04

          Canvas apps are still allowed to be 760px.

        • #12 by Nick - June 28th, 2010 at 08:15

          timware :
          Canvas apps are still allowed to be 760px.

          Great, so to clarify – this is considered a canvas app. Even though it’s presented via a tab on a fan page, it’s not truly considered an application tab – and therefore is not restricted to 520px. Just want to make sure I’m on the same page. Thanks!

    • #13 by Andreas Sefzig - April 6th, 2010 at 11:36

      You can definitely use FBML too.

      In some (some!) scenarios this even is the better option: You can render any site through the app’s fbml-interpreter, if you wish. Downside is, the app will throw errors for any not-supported tag. Upside is, you can implement fbml-functionality in your usual site (i.e. your blog) which will only show up if you render it through facebook. This might be great opportunity if you use Facebook Connect and empowers you to add facebook-specific features to your existing codebase. But be careful, there are many unsupported html-tags that can make facebook trip and fall…

  5. #14 by Derek - March 29th, 2010 at 16:51

    I believe I followed all the steps correctly, however, I’m getting the following error:

    Fatal error: Call to undefined function phprequire_once() in /home2/blah/public_html/websiterootfolder/US-page/appinclude.php on line 1

    • #15 by admin - March 30th, 2010 at 07:14

      Sorry Derek. I can’t troubleshoot PHP issues. I’d hit the forums: http://www.facebook.com/developers/

    • #16 by Gregory Edgerton - June 10th, 2010 at 06:21

      I think I had the same error in my code which I was able to correct. Check the source for your src/facebook.php file. It should be in a folder in the root location. I originally used a absolute URL for this file and it didn’t work. Once I removed the root it did.

      <?php
      require_once ($_SERVER["DOCUMENT_ROOT"] . '/facebook-platform/src/facebook.php');

      • #17 by timware - June 10th, 2010 at 06:36

        Ah yes, if you have the ["DOCUMENT_ROOT"] in there that takes care of “http://www.yourdomain.com”, so having that bit in the URL that follows wouldn’t work at all, as it’d be redundant. Thanks!

  6. #18 by Raza - April 8th, 2010 at 12:35

    Hello,
    thanks for your wonderful post! i used your method and its working great!
    i want to know how can i add a facebook application to my facebook fan page tab? or a direct site integrated on facebook page? Please Help!

    thanks

  7. #19 by elba - April 11th, 2010 at 10:52

    Hi,

    Thanks for the post. It was a big help. Has somebody a tip to how to remove the “Activate” link after the user clicked on it? It is kind of annoying after the iframe has loaded.

    Thanks in advance.

    • #20 by timware - April 11th, 2010 at 11:33

      Your solution is right in this post! Please read the entire post before posting a question. Thanks!

      • #21 by one7 - April 30th, 2010 at 16:56

        guess i missed it too..can we get a one word hint…

        • #22 by timware - May 1st, 2010 at 17:58

          Hah! Well, to my embarrassment I hadn’t included this bit of information. So take a look in the post now. It’s there, in all its splendor :)

  8. #23 by arena - April 14th, 2010 at 02:05

    Hi, Timware

    nice post.

    My app works great. here is the Canvas URL : http://apps.facebook.com/test_mailpress/

    However i am still struggling to get this app (an iframe with a subscription form doing ajax with my own website) into a widget i could include in a Fan Page or best in any fb page.

    Thanks for your help and your time

    • #24 by timware - May 1st, 2010 at 17:41

      If you’re using an iframe in your app, you need to have an activation image or text that the user clicks before the iframe loads. If you don’t have the activation image/text for triggering the iframe (and how to do this is explained in the post), then your iframe will load on your application page, but it won’t work when it’s pulled in as a tab application.

      • #25 by arena - May 11th, 2010 at 06:26

        thank you timware to confirm what i read.

        btw i am wondering how these guys can have an ajax form on their fb wall (or is it a fake wall page ?) ?
        any idea ? would be nice to have your expertise/feedback.

        http://www.facebook.com/cluster.efectos?v=wall

        • #26 by timware - May 11th, 2010 at 08:32

          If you’re talking about the yellow form in the left column box, it appears to be a valid form. I didn’t test it. But all the left-column box stuff is going away soon anyway. Currently you can’t add anything to the left column boxes.

  9. #27 by nicos - May 3rd, 2010 at 09:22

    Thank you very much for the tip ! works great, my boss is happy and me too… even if the ‘click to activate’ is not an ideal solution, it works !

  10. #28 by Jeanne - May 6th, 2010 at 10:02

    in the appinclude script above, I see this:

    // *** Add your Facebook API Key, Secret Key, and Callback URL here ***

    So I see where to add the app key adn secret key. Does the callback url go next to “$facebook = “? like this:


    <?php
    require_once ($_SERVER["DOCUMENT_ROOT"] . '/facebook-platform/php/facebook.php');
    // *** Add your Facebook API Key, Secret Key, and Callback URL here ***
    $appapikey = '[DELETED]';
    $appsecret = '[DELETED]';
    $facebook = 'http://www.mycallbackurl.com($appapikey, $appsecret)';
    // $user_id = $facebook->require_login();

    ?>

    Also, I keep getting errors regarding this line:
    require_once ($_SERVER["DOCUMENT_ROOT"] . '/facebook-platform/php/facebook.php'); – I have pasted that *as is* into my file. Was I supposed to change any data in this line of code?

    Thanks!!

    • #29 by timware - May 6th, 2010 at 13:47

      Jeanne, Thanks for this comment. I needed to update this post in light of the new Facebook API and because I omitted an important piece of information — downloading the Facebook PHP 5 (or PHP 4) Client library and installing it on your server. This is where the “require_once” in appinclude.php points and it’s essential that it’s present on your server. Sorry for that! And, for the “$facebook =” part, just use what I have in my example rather than the “mycallbackurl.com” that you have.

  11. #30 by Nick - May 20th, 2010 at 14:51

    Fantastic tutorial, thanks! I have my test application working if I browse to the url directly – how do I go about adding a tab to my new app on my fan page? Also, strangely – my iframe content seems to render immediately, not requiring the click to activate. Did anything change recently in FB policy that would explain this?

    • #31 by timware - May 20th, 2010 at 18:06

      You need to add the app to a fan page. Then it’ll show up as a tab. When you’re viewing the app directly rather than via a fan page, the iframe will load without a user action. Once it’s a tab on a fan page, then it won’t load automatically.

  12. #32 by Esteve - June 3rd, 2010 at 09:06

    Amazing post. And I’m sorry is this is too basic but I’m struggling. I’ve developed an app and it is working fine, and I want the app to be used from a fan page (in a tab). So I realized I need to provide a link to a page inside Profiles section an a tab URL.
    What is this TAB URL useful for? Do I need to rewrite my application to be only in FBML (even though I’m pretty sure it is not possible?)? The way facebook has thought it’s to rewrite the application once for a canvas page and another for profile page?

    Thanks in advance,
    Esteve.

    • #33 by timware - June 6th, 2010 at 18:09

      The Tab URL is where Facebook will pull the content for your iFrame Canvas App. You should first fill in the Canvas Page URL (under the Canvas tab). Then fill in the URL under “Tab URL” — I always use “index.php” in the URL. As it says: “Facebook pulls content for your tab from this URL, which must be relative to your canvas page.” Here’s a good resource for creating canvas apps: http://forum.developers.facebook.com/sandbox/viewtopic.php?id=9074

  13. #34 by timware - June 28th, 2010 at 09:09

    Nick, It is my understanding that canvas applications are still allowed to be 760px in width after the application-tab width is shrunk to 520px. Canvas apps can, and usually are, presented on the page as tabs.

    • #35 by Nick - June 29th, 2010 at 11:57

      great, thanks!!

  14. #36 by Mathias - July 7th, 2010 at 01:57

    I found a little bug in the Iframe script when implementing it on a static FMBL page with a visible to connect tag.

    The code doesn’t work if the screen is refreshed.

    Javascript error something like link_1 doesn’t exist.

    I tried moving the link part above the clickcode but it doesn’t seem to help.

    Any idea how to fix this?

    • #37 by timware - July 9th, 2010 at 11:41

      All I can say is that you CAN’T use iFrames in Static FBML, only in iframe canvas applications.

  15. #38 by Peter from; Miami Web Design - July 14th, 2010 at 09:08

    Very interesting since I had no idea you could add iframes to facebook.

  16. #39 by Nick - July 14th, 2010 at 10:00

    Hey Tim – Seeing a strange issue, wondering if you’ve come accross it. In my app I have a gradient bkd image on the body tag that lays on top of a solid html bgcolor. In FF, mac only, when viewing the application through the FB iframe only, when I click on any of my links, for a split second, only on mouse click, the block area of the a tag loses any background, and shows a quick block of the solid html body color. That same code when browsed directly in FF/mac is fine. It is fine in all other browsers both browsed directly, and through the FB app. Have you come across anything similar in your experiences?

  17. #40 by Nick - July 14th, 2010 at 10:02

    Actually – it’s not on click, but on release, or mouseup.

  18. #41 by Chuck - July 19th, 2010 at 15:12

    Question – my app is running on a profile tab with no problems EXCEPT it won’t allow the share to newsfeed/post to wall popup to appear. I’ve seen this happen with other applications (see the Alice in Wonderland official app). Any ideas if there’s a workaround?


(will not be published)

Be sure to wrap all code in <code></code> tags.

Submit Comment