Facebook apps, huh?
So I’ve been lucky enough to get some exposure to building out Facebook apps, and I’ve come across some key things I’d like to share in the hope that I save someone else precious minutes of their life.
First of all, when you initiate your page, you set up something called a Canvas URL. For a while, I thought that this was the only way to view a facebook app, but that assumption was so so wrong. Let’s say you wanted to house the application as part of a page, and only wanted the app to be accessible for people that have liked said page. You’d have to get something that facebook calls a signed request on the page load. The signed request carries a bunch of useful data with it, and if you want to test whether a user has liked your page or not, you’re going to find it in the ‘page’ part of the signed request object (exactly how you’d access the ‘page’ information depends on how you decode it. For my particular app, I did it via PHP). Only the page part of the signed request data isn’t passed when you decode the signed request on the canvas page. Well, if you’ve just started up an app and havent done much with it, that’s because the app has not been associated with any particular page. And even if it was,the signed request still won’t pass page information to the canvas page. This kind of makes sense in a Facebook way – the probably want apps associated with pages to appear in a particular format.
However, there’s let’s back up to the first issue - the app has to be associated to a page. There’s no obvious path to doing that, even though it seems like wanting to assign an app to a page would be pretty common. So let’s take it from the top – let’s say you’re looking at the Developers Homepage (http://developers.facebook.com). Currently there’s an option that says ‘Apps’ on the main menu. Failing that, you can go directly to https://developers.facebook.com/apps.
Once there, click on the app you want to edit (currently being displayed on the left hand menu). If you don’t have an app made yet, make one. I’m not going to cover that here, mainly because it wasn’t super frustrating sticking point. Once there’s an app to edit, click on ‘Edit App’ in the top right hand corner of the area which displays the app info. Once the page loads, the left hand column will have a couple main areas towards the top, but guess what? The settings to link your app to a page isn’t in any of these. Instead, check out your related links towards the bottom of the left hand column. Somewhere in there, you’ll see a link that says ‘View App Profile Page’. What? Yeah, go in there. You can adjust some settings there as well.
The App Profile page looks like a conventional facebook Page / Profile. Now look in the left hand column of the App Profile page, towards the bottom. There’s a link that says Add To My Page. Ta-da! That’s where you can associate the app to a page. Once you’ve made the association, you have to check some other things. First, on the Edit App screen (the one with all the options on the left hand side that does NOT look like a normal facebook page), make sure you have given the app a Page Tab Url. Second, you may actually have to go into your page adjust the settings. From the Page (arrgh, what? that’s right. I recommend opening a new window to help keep your place in the developers section of the site while cruising the conventional Facebook site for your page, which can be a chore in itself). Once you find your page, click on the edit page link – it should be in the upper right corner like the Edit App link on the developer site. Then click on Apps and find the newly added application. Click on Edit Settings link next to the app and then ‘add link’ in the window that pops up.
Now you can go to your page and click the link for the app. When it loads in this ‘Page Tab’ view, it will carry with it a more robust version of the signed request than is normally found when loading the app via the Canvas Page URL. You can use this view to do whatever tests you require that revolve around those features of the signed request. Of course, if you’re planning on assigning your app to a page that generates decent traffic, I advise taking some precaution, like creating a page for development purposes and assigning the app to that until it’s ready for production.
I’d like to thank Facebook for giving me so much to say in regards to what should probably be a minute concern in the app development process. Hopefully this rights the ship for a few frustrated people out there, I know something of this nature would have helped me save a lot of time and pointless clicking.
EDIT: See this note by Hyperarts for more info on developing an app for Page Tab usage.