This post is part of a series about making a Facebook game from scratch in one week. Go read the Overview to find out more and see a list of all the posts.
More Facebook Integration
The bulk of my day so far has been spent getting authentication working in a sustainable way, and then implementing some controls and features on top of that. Did you know that Facebook doesn't provide a way to tell if your access token is expired or not? Yeah, you're supposed to detect the error any time you make an API call and then re-authenticate. That could lead to a lot of repetition, so I wrote a wrapper to handle it, but seriously, shouldn't the SDK at least help with this sort of thing? The old API also had a quick method for getting the ID's of a user's friends who also had your app installed. Not so anymore.
It's having to deal with a couple dozen realizations like those that slowed me down yesterday. Progress has been better today, but it's really just an extension of what I didn't finish earlier.
I've switched the invite page over to pure FBML, and the speed increase is frightening - 5 seconds instead of 55. But here's something I was stuck on today for hours: Facebook only does POST requests to FBML pages, never GET. Why? I have no idea. Now if only they had some sort of error message that said as much... The final catch with FBML is that the domain the page is on becomes facebook.com, which means that any cookies you have - or sessions that rely on cookies - are no longer accessible. However, if all you need is something like the user's UID to look them up in your database (this is what I was passing around in my session) then Facebook has you covered by means of parameters sent to your page. Just check for "fb_sig_user" and you'll be back in business.
I also wrote some code to post to users' walls. I've never done anything like that before, and it feels like I have a lot of power with this ability. I'm trying to respect that and keep things to a minimum: one post per battle, and then any updates are comments to that post.
I was originally planning on just doing this within a "business week" of five days, but in order to give this project the treatment it deserves, I'm re-interpreting "week" as a seven days. I need the time because I still need to style just about everything, and create several logos for the game. It's work I'm looking forward too though.
Daily Wrap Up
Now for some stats about Day 5:
- Working Time: 7 hours
- Number of Commits: 6
- Total Number of Files: 62
- Total Lines of Code: 1663
Update: Go on to Day 6.