Facebook's so promising as a solution to the distribution problem, I'm learning more about the technology so to see if there's a way I can use it. I'm a client-side guy, I've done very little server programming, so I'll be documenting what I learn for the benefit of other server-side newbies.
To start with the basics, you'll need a facebook account. Once that's set up, go to the getting started page on developers.facebook.com. Add the developer application to your profile, that gives you access to the control panel for registering new applications with facebook.
Facebook offers a wide range of documentation, including a step-by-step tutorial, a wiki and an API reference. If you're like me, and learn best by doing, the best place to start is their sample application, which you can download and get started with right away.
As the getting started page says, once you've downloaded the sample app "open your favorite development environment, and you're ready to go". The assumption is that you're an experienced server-side developer, but if you're a newbie like me you'll have to make some choices about what to go with. My recommendation is PHP, it's probably the most common server-side language, and it's what the official Facebook client libraries and sample application are written in, though you can download unofficial versions for most server technologies. I've also hacked in PHP a bit before, and I'm fairly comfortable with it since it's very C-like.
Now, you'll need your own server that you can host the application on. You'll need one that you can access the unix shell on, through ssh, so you can set up the application, and one that supports PHP 5 (though 4 is also unofficially supported).
I've been using WebHSP for about five years, I'm fairly happy with them, event though I have an ancient hosting package they've been reliable and have a web interface I'm very familiar with. A few months ago they turned off ssh access by default, which I wasn't using too much at the time for the mostly-static web pages I host on there. So, I contacted their tech support to get it re-enabled.
While I was waiting for that, I decided to check out alternative hosts, since I knew I wasn't getting a good deal anymore with WebHSP, and they are aimed very much at non-technical hosting. I was suffering a bout of irrational exuberance, so I also wanted somewhere that could scale up if a facebook app I wrote went viral. I first ran across dreamhost when Seth Godin posted about the way they dealt with a nightmare power outage issue that took their sites down repeatedly over three weeks. This may not sound like a promising start, but I was impressed by how well they dealt with customer communication, they're based locally in LA, and they're obviously run by techies, for techies, so I decided to give them a go.
I got their basic plan, with bandwidth and space limits so high I didn't even bother to remember them, for $8 a month if I paid for two years in advance. Once I'd paid, I then had to wait a couple of hours before I could try out my domain, since they only offer access through the yourname.dreamhosters.com url, and don't have a unique IP like my last package, so I had to wait for DNS to trickle through. For some reason, I thought DNS propagation only applied to the top-level domain resolution (eg as long as it could work out what address dreamhosters.com was from the .com servers, it would fetch the sub-domain directly from a DNS server associated with dreamhosters, rather than reading from a cache somewhere else), so I complained to tech support about the delay, but they patiently explained the issue.
Once that was working, I had to turn PHP support from 4 to 5 in their control panel, and then I was ready to upload my app. I set up an ssh shell account in the control panel, and logged in to test. Then I did an scp of the sample application up to the server, using a command line like this:
scp facebook-platform.tar.tar myusername@loginserver.dreamhost.com:myhostname.dreamhosters.com/facebook-platform.tar.tar
You'll need to replace the italics with your own details. On windows, make sure you've got the cygwin package installed and in your path to use some of these useful unix commands from the DOS prompt, it makes life so much easier, and on OS X of course you get them out of the box.
Then, I logged in using ssh, went to the directory where I'd uploaded the tar file and did this to extract it into a folder:
tar -xf facebook-plaform.tar.tar
This left me with a facebook-platform folder full of other folders and files. The next step involves sorting out the config files and mysql database for the sample app itself, and I'll describe that in the next article.
Comments