How a Facebook app can change its own tab name
August 28th, 2010The mysterious admin.setAppProperties holds all the secrets.
The mysterious admin.setAppProperties holds all the secrets.
As any Facebook developer knows, Facebook has some restrictive ideas about permissions and what apps should be allowed to do on your behalf or even know about you. One consequence of this is that Facebook avoids giving you any information about the user who is interacting with your app in a tab. The session data you are given will contain the page’s id (known as profile_id in the decoded signed_request value) but not the user’s id. The user’s id is available when people interact with your app outside of a page tab, but that doesn’t help when it’s in a tab.
Aside: New developers, always remember that Facebook gives you more or less access to the platform depending on how the app is being used. If your code doesn’t seem to work when running in a tab, try running it directly through the canvas at http://apps.facebook.com/[app-name]/. If it works there, you probably have some permissions weirdness going on.
So, how do you determine the user id of the person who installed your Facebook app as a tab on their fan page?
There are three ways to do this that I’m aware of. If I missed anything, let me know.
app_installs. In there, track page ids that have installed the app, saving all the information you can find about them. Create a setup or edit page, and put that in the Edit URL field of your Application Settings. When your app is loaded, check that app_installs table to see if a record already exists for the page id (profile_id in signed_request). If it doesn’t, instruct the user to click the Edit Page link, then find your app and click Edit. Your app will run in canvas, as the user who admins the page, with both the profile_id and user_id variables available to you! Store this information, update the app_installs table, and you’re good to go! This might also be a good place to do some queries against the page and user FQL tables and store the information in your local table. <fb:visible-to-owner>>a href="[encoded_secure_edit_url]">Click here to finish setting up the app</a></fb:visible-to-owner> construct to build a secure edit URL (perhaps based on a session key or md5'd profile_id/APP_SECRET combination). Facebook will only show this link to the page admins, and then you will be able to get the rest of the user information after the click. Hope this helps some struggling Facebook App developers!
The <fb:tabs> and <fb:tab-item> FBML tags are very handy to use in your Facebook apps if you want to maintain the Facebook appearance. Unfortunately, they also have weird target behavior that causes the user to leave your application’s frame - if it’s an FBML canvas tab app, and you want to keep your app inside the tab for layout reasons, this is bad news.
To fix it, consider emulating the appearance of Facebook’s <fb:tabs> using CSS.. read on for our solution.
I’m doing a lot of Facebook App development lately, and I’m finding the internet to be sorely lacking in good resources for a lot of this stuff. So on this blog in the coming weeks I’m going to feature a few tips for the greater good of the web.
Editor’s note: This is actually a very old post, from around May of 2005 if I recall. I’m making it live now because it was too painful to make live before, but the attic needs to be swept out from time to time.
I’m writing this even though Coco St. Coco doesn’t read my site that often. I don’t think he’s really feeling the whole blogging craze. I’m hoping that maybe they have internet cafes in doggy heaven and they don’t filter the websites of atheists.
I don’t know if this is an obituary. You’ve been gone for almost a week. You could come back but a part of me lost hope. I stopped leaving the back door open in case you found your way home. It’s locked now. All the flyers we put up — hundreds of them — have fallen down cuz of these torrential rains. Did the rains keep you in the bushes, under cars, causing us to not spot you as we wandered the blocks of this new neighborhood endlessly, such a poor way to familiarize myself with it.
You were the only A+ on the list of things I own. For two years, you were my best friend. You understood me more than anyone, which is to say you didn’t understand me at all, which is still more than anyone. The stairs in this big new house — the one that freaked you out so bad you had to run away — aren’t the same without the sounds of your little claws clittering up ahead of me, ten times faster though you’re ten times smaller.
My favorite memory of you is from early on. We went to Green Streets in The Grove and you ate so much bread and veal (so cruel) and so much other shit. You ate more than your own weight. When we got up to leave, you ran into the restaurant and to the horror of everyone around took a big shit right inside the door. An act of pure uncaring defiance. Those are the moments I remember most.
I don’t know if you’re dead or if you’re bringing the same joy to another family that you brought to mine. In any case, I love you and I will never forget you. I’ll keep some food around in case you decide to come home.
The complex intellect of ravens has me rethinking my recent dietary changes to be more morality-compliant. I gave up red meat but kept chicken, and I’m starting to think I may have to axe the fowl entirely. Dohhh.
I don’t need you selling your users to your sponsors over a few hex digits. Reddit has a better algorithm anyway.
Oh, and 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0.
For a while I’ve had sporadic problems with pecl (PHP’s binary module building tool, part of PEAR) not working properly. Usually the error was:
[root@host ~]# pecl install memcache
Fatal error: Call to undefined function preg_match() in /usr/local/share/pear/PEAR/Frontend/CLI.php on line 70
Yet, preg_match() would work from other scripts - it is part of pcre, which was installed.
The problem is this. pcre is included via extensions.ini. That’s why it usually works. However, pecl for some reason deliberately turns off .ini file inclusion (that includes extensions.ini) when it runs the php interpreter. I’m not sure what the objective was here but it’s a problem on FreeBSD’s shared library pcre.so.
The fix: edit the pecl script (usually /usr/local/bin/pecl) and remove the ‘-n’ from the command line arguments.
Check out this Hummer running the quarter mile in 12.8 seconds: