Facebook Cookbook - Jay Goldman [47]
Figure 5-1. Becoming a test account
WARNING
This is very strong magic! Be very, very careful. Test accounts are like the Matrix: once you’ve swallowed the red pill (or gone to the URL just listed), there’s no way to go back to living innocently in your pod. Don’t do this step from your primary Facebook account or you’ll have banished yourself into Test Account land.
Discussion
Here are a few useful tips on using test accounts:
Test accounts can be really handy, but the fact that they can’t own applications (which really means not being registered Developers of an app) means they can’t see apps that are in Developer Mode and therefore can’t be used to test an app that isn’t yet public.
You’ll need a unique email address in order to sign up, but coming up with different addresses for each account can be a pain. If you have a Gmail account, take a look at so-called “dot addressing.” Gmail doesn’t recognize dots inside of your email address, so bob.dylan@gmail.com is the same thing as b.obdylan@gmail.com and b.o.b.d.y.l.a.n@gmail.com, in that they’ll all get delivered to you. Facebook sees them all as different addresses and will let you sign up as different accounts. Gmail also has a much more useful “plus sign addressing” feature in which it ignores everything after a plus sign in your address (so bobdylan+test1@gmail.com is the same as bobdylan+test2@gmail.com), but unfortunately Facebook won’t allow plus signs in emails.
Facebook login sessions persist across all the tabs and windows in your browser through the use of session cookies, but they can’t persist into different browsers. Since you’re a kick-ass web developer and you already test in Firefox, Safari, and IE 6/7/8 on Windows and in Firefox and Safari on Mac, why not log into Facebook with a different test account on each platform? That way you cover different browsers and different users at the same time.
Facebook Clients
Problem
I have a good grasp on my idea and how to build it, but I need to find the right Facebook client for my development environment before I can get started.
Solution
Most of the resources you’re going to need to get started can be found on the Facebook Developers site at http://developers.facebook.com.
Discussion
Facebook officially supports Client Libraries for PHP 4 and PHP 5, which you can find at http://developers.facebook.com/resources.php. Facebook has also recently launched a JavaScript Client Library (which was still in beta at the time this was written), which you can find at http://wiki.developers.facebook.com/index.php/JavaScript_Client_Library. There used to be an officially supported Java library, but it’s been discontinued (presumably due to a lack of interest).
If you’re intent on using a different language and don’t mind that its Client Libraries might not be up-to-date, you’ll find a full list on the main page of the Wiki at http://wiki.developers.facebook.com/index.php/Main_Page (including ASP.NET, Perl, Python, Ruby on Rails, etc.).
The PHP Client is currently missing four methods that are available through the API: Photos.createAlbum(), Photos.upload(), photos.addTag(), and Users.hasAppPermission() (see Adding Missing PHP Client Library Methods). You can use a third-party extension to get around the fifth method (see Uploading a Photo).
JavaScript Client Library
Problem
I’d like to use the JavaScript Client Library to access the API, but I want to make sure I understand any potential limitations and how to get set up before I jump in.
Solution
The JavaScript Client Library is a new addition to the Facebook family and was still in beta at the time this book went to press. The biggest advantage is that you can use it from an HTML page with no server-side code required, which can be served up by Facebook either inside an iFrame-based app or inside an fb:iframe in a Canvas-based app. This opens up the possibility