Facebook Platform updates – w00t!
According to this blog post over at developers.facebook.com, some exciting changes are coming to the Facebook Platform.
I'm a little slow on the uptake here, the blog update I'm referring to is now 10 days old. I haven't been in the Facebook dev world of late, so I hope you'll forgive me for regurgitating old news.
The big update for me is in the 4th paragraph:
We are also moving toward IFrames instead of FBML for both canvas applications and Page tabs. As a part of this process, we will be standardizing on a small set of core FBML tags that will work with both applications on Facebook and external Web pages via our JavaScript SDK, effectively eliminating the technical difference between developing an application on and off Facebook.com.
This is excellent! I have actually been holding my breath for something like this for a while now. The restriction of FBML only content for tabs has been extremely restrictive, here are a handful of reasons why:
- Very strict HTML parsing - because the Platform was rendering tabs inline previously, it of course had to be VERY careful in how it handled offsite data, to protect users from all manner of scams/attacks. Now full flexibility is available because your iFrame is yours to control.
- Insanely strict JS parsing - same as first point, application tabs could only leverage basic Javascript and the unwieldy, poorly documented FBJS (Facebook Javascript). Now, you're free to access manipulate your IFrame document/window objects, DOM manipulate, include third party JS libs, etc, all to your hearts content.
- Embedded media was a pain - Granted, the tab FBML *did* allow you to embed Flash and AIR apps etc, but there were countless threads on the forum outlining issues they were having interacting with the host page, etc.
- Tab activation policies - There were some extremely frustrating rules with the way tabs were allowed to be "activated". No JS/FBJS was allowed to execute until the user had interacted with the tab in some manner, such as focusing a form element or clicking somewhere. This made it very cumbersome to implement any meaningful interactions with the user; alot of obnoxious boilerplate code had to be written for various ways in which you may actually start doing anything meaningful from JS, like AJAX requests.
- ... and lots more Everything from CSS parsing to the occasional time where the tab would just sit in an endless loading display when clicked. When I was writing a tab page I remember bashing my head against the wall trying to get some content to sit nicely in a cross browser fashion... it would have been easy under normal circumstances, but the Platform tab flavour was refusing to accept the *display: inline IE hack in the CSS. Joy.
This is going to really open up some great possibilities for interactive, rich web applications. I really cannot wait for this feature to be rolled out.
This news does come with some disappointment however; the sixth paragraph on the developers blog states the following:
Finally, due to low usage rates, we will remove application tabs from user profiles in the next couple months. Application tabs will continue to be supported on Facebook Pages.
There are plenty of great use cases to have application tabs on a user profile page. My personal Facebook profile has a tab that displays my latest last.fm scrobbles, my latest blog posts, etc. Personally, I believe that if the adoption rate for user profile tabs is low, the Facebook team should be coming up with ways to increase user acceptance of this feature, rather than removing it all together. Besides, the functionality in Facebook Page tabs is pretty much identical to the user profile equivalents... Why not support both?
There's other goodies in the developer blog update too, such as cleaning up the REST API considerably.
All in all, exciting changes coming to the Facebook platform in the coming months!
Spring Roo
So I stumbled across Spring Roo a couple of times recently and haven't really looked into it much. I finally decided to do a little bit of reading on it, starting here. It seems like a pretty fascinating tool, providing intelligent tools to help develop an application without layering any actual IDE requirements, runtime libraries, bloated annotation models into the mix. I'm also especially interested to see exactly how this works in practice with Google Web Toolkit, as it could provide a very powerful framework to develop rich web client functionality and robust backend datastore+business logic facades very rapidly.
When I get a bit of time soon I'm definitely gonna check this out further and post more thoughts on it.
Gotcha: Removing iframe border in IE.
Think I'm gonna start a little mini-series of blog posts with the little "gotchas" I run into during the course of an ordinary day at work. Some of the pitfalls I've run into lately have been ridiculous. Bloody IE!
Todays one is a fun one. Removing a frameborder on an iframe in Internet Explorer is case-sensitive, would you believe it!
That is to say:
<iframe frameborder="0" src="http://www.google.com.au/"></iframe>
.. Probably won't work. Whereas:
<iframe frameBorder="0" src="http://www.google.com.au/"></iframe>
Will!
This also extends to creating an iframe using DOM. You need to do this:
Think I'm gonna start a little mini-series of blog posts with the little "gotchas" I run into during the course of an ordinary day at work. Some of the pitfalls I've run into lately have been ridiculous. Bloody IE!
Todays one is a fun one. Removing a frameborder on an iframe in Internet Explorer is case-sensitive, would you believe it!
That is to say:
myIframeEl.setAttribute("frameborder", "0");
Is not going to work in IE.
myIframeEl.setAttribute("frameBorder", "0");
But this will.
Facebook Access Tokens from Canvas Apps
UPDATE 26/07/10: looks like the Facebook Platform team is addressing this issue presently. There's a new migration option available to send session data in the request. When I used this parameter it seems that all old session related fb_sig parameters were no longer being sent, so I'd probably avoid using this. Instead refactor your applications to use the new OAuth support for Canvas apps, which is also available to enable in the App Settings Migration tab.
There's an open bug over at the Facebook bug tracker detailing an issue people are having with Canvas pages and the new Graph API. Right now, Facebook canvas applications are posting a session_key to the canvas callback URL. The new OAuth system of course uses the access token system, rather than the session_keys from the old Rest API.
There's a bit of info hiding in the documentation upgrade guide that outlines how to "exchange" a session key for an access token. All you need to do is POST some info to an endpoint and it'll spit back a valid access token.
Like so:
$ch = curl_init("https://graph.facebook.com/oauth/exchange_sessions");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
"type" => "client_cred",
"client_id" => "<your canvas application id>",
"client_secret" => "<your canvas application secret>",
"sessions" => $_REQUEST["fb_sig_session_key"]
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = json_decode(curl_exec($ch));
$accessToken = $result[0]->access_token;
So what's going on here? You're POSTing a request to the Facebook OAuth implementation to exchange your session key for an access token. You provide your application id and secret (important: this needs to be id and secret for the canvas application the request originated from of course) and the session ID of the user. Send this off and a JSON response will come back with the access token. Also, if needed, there's another property passed back - "expires", which will let you know when this access token will die.
Okay, so now you have an access token for use with the new API. Now what?
There's a little bit of fudging required to use this with the PHP SDK. The setSession() method of the PHP SDK doesn't just take an access token, it expects all the other crap that is usually contained in the cookie it saves. The idea behind my solution is that you shouldn't need to modify any base classes. The code below will con the Facebook library into accepting your newly acquired access token:
$session = array(
"uid" => "",
"session_key" => "",
"secret" => "",
"access_token" => $accessToken
);
ksort($session);
$sessionStr = "";
foreach($session as $sessionKey => $sessionValue) $sessionStr .= implode("=", array($sessionKey, $sessionValue));
$session["sig"] = md5($sessionStr."<your app secret>");
$facebook->setSession($session, false);
What this code is doing is constructing a fake session object. Since the only thing the SDK actually looks at in this session data is the access_token, we just fill the other entries with an empty str. Once this is done, we just calculate a signature for the data, as per the Facebook Wiki documentation. Again, we're only doing this because the setSession() method demands it.
Once this is done, you can go ahead and make api calls! Now wasn't that easy?
Also, as a little footnote, you should know that you don't actually have to fudge the session, you can just pass the access token you get into each api call, like so:
$facebook->api(array("method" => "stream.get", "access_token" => $accessToken));
... But this is a bit cumbersome. Also, with the fake session, you can just remove my code later when Facebook starts sending access token in the initial POST data.
You can see this solution in action at this Facebook page. Just click grant access, then click Go.
Hope this helps someone!
Facebook Platform Bugs
Sup peoples.
Please, for the love of god, sign up a Bugzilla account at developers.facebook.com and vote up a few bugs that are really starting to piss me off in the land of Facebook!
Bug #10291 - an annoying bug that prevents proper auto configuration of a Facebook Application using application.setProperties.
Bug #10454 - another fantastic little issue that causes permission dialogs in Profile Tabs to do weird stuff...
Bug #8260 - a bug that prevents a parent Facebook application from modifying the settings of a child application that was created by it.
Just a small taste of the bugs that are plaguing me at the moment.
Periphery/Maylene/Dillinger Concert
Went to the Hi-Fi last night to see Dillinger Escape Plan play, with Periphery and Maylene & the Sons of Disaster supporting.
Periphery kicked off, I've been listening to their album a lot the past week or two, as a result I was pretty much going to the concert for them more than Dillinger (as I've seen Dillinger play before). I was not disappointed, from the moment the curtains drew and Jake Bowen flips his guitar over and implores us for weed with a sign made out of duct tape: "Need Weed". The played an amazing set - I was worried that the magic that is their music might be nothing more than some amazing mixing on the album (which you need to go buy right now, btw). This fear was quashed as soon as they exploded into their first song (I honestly can't remember which they played first). When they started playing Light as their second song I was lost in a frenzy of neck spasms. True story. The only thing that made me sad about their set was the distinct lack of a crowd - being the opening band of course a lot of people are going to be stupid and come late to see Dillinger, but there was a lot of people just standing around and not giving an amazing band the support they deserve. Hopefully next time they come to Australia they're greeting with a far more energetic crowd.
Maylene & the Sons of Disaster are a band I listened to a little a couple of weeks ago (to get a feel for them). I have to admit, I didn't really like their albums much, but they played a pretty engaging set. The mosh was pretty full-on all the way throughout too - though I didn't join them, saving myself for Dillinger and stuffs
Maylene trudged off the stage and the wait for Dillinger began. Their soundcheck took a while, as did Maylene's, so they ended up starting about 20 minutes late. By the time the curtains opened to Dillinger, with Jeff Tuttle predictably perched on an amp stack, the crowd was pretty pumped. They opened with Panasonic Youth, and within 3 minutes I was drenched in sweat and totally ballistic. I'm not even going to bother trying to paint the picture of a Dillinger set in words, it's something you need to experience to believe. Needless to say, it's probably one of the most energetic, chaotic, unpredictable shows you'll ever see.
Greg was in top form, spending more time singing while leaning into the crowd than on stage. Having been in the mosh, I was thankfully not in the particular area that Greg decided to dive into several times. He is one big dude, I'm not sure how I'd do having 90kg of muscle and lungs landing on me. At the end he crowd surfed over me, and that was intense enough.
Ben Weinman's frenetic guitaring was truly a sight to behold. That guy is just a machine. I was near him most of the set and it was just insane watching him go up and down the fretboard like some kind of possessed lunatic. I actually had no idea, but Ben plays the piano now... They played Mouth of Ghosts and he switched to piano for that song, I have no idea if he composed the original piano stuff on that song, but he played it nonetheless. Unfortunately as soon as they begun the song they discovered there was something majorly wrong with the piano ... It sounded bizarre the whole song ... Was a little disappointing.
Billy Rymer is just unbelievable. Playing stuff from the earlier albums (Sugar Coated Sour, 43% Burnt, The Mullet Burden, When Good Dogs Do Bad Things) to the more recent stuff on Miss Machine and Ire Works, along with his own frenzied percussion on Option Paralysis. He covered the work of two drumming predecessors with ease, making it look like he could do it in his sleep.
The crowd was a lot of fun, with plenty of burly drunk 30-somethings throwing their weight around and crushing me into a pulp. On more than one occasion, some retard behind me grabbed a scruff of hair at the back of my head and rammed my head forwards, ripped it backwards, rammed it forwards, in some kind of weird attempt to make me headbang. Besides the fact that this kinda hurt and I can't really move my neck properly right now, I was quite offended! I was headbanging uncontrollably most of the night! Dumbass drunks.
The set ended with Ben Weinman slamming his guitar into the drum-kit repetitively, and Greg grabbed a piece of said drumkit and started throwing it around the stage. Band exits. Just another Dillinger set.
But wait! Just before the curtains close, Greg comes back out, grabs a mic and thanks us for being such an awesome crowd. Damn straight.
The Facebook Platform
Over the past few days I've immersed myself in the engaging, complex, diverse, exciting and downright confusing land of Facebook development. I'm currently writing a WordPress plugin that integrates a blog fairly extensively into a Facebook Profile Tab. With the bulk of the functionality now written, I can step back and reflect on the experience as a whole. I'm now going to post some thoughts on it.
In a word - wow. The process has very much been a rollercoaster ride, let me tell you. I picked a bad time to launch into this project - Facebook is in the process of transitioning from "Facebook Connect" to the new Graph/"Facebook Platform/Open Graph/whatever branding, bringing a slew of new APIs, SDKs, and other changes along with it. For example, right now if you visit the Facebook Developers website, they're trying to rework all the documentation, hiding the original Developers Wiki in the process, leaving a HUGE gap in the documentation in the process.
Further, right now the Platform as a whole is riddled with inconsistencies in terminology and functionality. What's worse is the transitory phase is obviously quite involved, and there's bugs all over the place.
That being said, the Platform is a pretty sexy wonderland of functionality. When I wasn't encountering odd issues or server latency dramas, it was pretty cool to work with such a diverse environment. That being said, I haven't actually worked with the Graph API much yet - the application I wrote needed to be integrated into a profile tab, which still only supports FBML/FBJS - no iframe support yet.
I'm going to be posting alot of articles here over the coming weeks/months with nifty things I've discovered and "gotchas" I've worked around in the land of Facebook. Also, I'll be putting more info up here soon for the plugin I'm developing that I mentioned earlier, currently dubbed "Faceblog" - not sure if I'm gonna have troubles with this name yet
Stay tuned!
Album plug: Converge – Axe to Fall
So I've covered one or two albums in the past here on my blog that no one really reads. Hearing my imaginary readers pleas for more... more.... MORE ... I feel I must accede to this request, in the face of so much wild demand and popularity.
This time around, I'm going to cover a certain album I've been listening to nonstop for a few days now. This one is for the crowd out there who appreciates the heavier side of music, and a bit of the ol' "cookie monster vocals".
Today's album is Converge - Axe to Fall
I'm embarrassed to say I actually had this album lying around for a couple of months before I got around to listening to it. I've been a little closed-minded in recent weeks, and haven't really been trying new music out. I've never really listened to Converge, however Axe to Fall is their seventh studio album since they started in '94.
The first time I listened through this album, my media player failed, and 3 songs were missing. You probably won't believe me, but when I queued this album up for the first time at work and listened through, when I finished the last track I honestly felt like there was something missing. Once I fixed the missing tracks (Effigy, Wishing Well and Cruel Bloom) up, I gave it a second listen.
This album blew my mind.
The album begins with Dark Horse, a relentless track that holds nothing back, from the intro right through to the final moments. The band then barrels into Reap What You Sow, which I thought sounded very early-Mastodon-esque, like a fusion between Lifeblood and Remission. Again, another uncompromising track that leaves you dizzy by the end.
From here we move on to the title track - Axe to Fall. I dunno what to say here, great track, however it didn't really do much for me. The next track however, is probably my favourite on the album - Effigy. At this point, there's been no breaks in the album, just one track careening into the next. Effigy is no exception, the track begins with some spastic jazzy drumming just like Dark Horse, and then launches into some CRAZY riffing and noodling. It's just 1:44 minutes of insanity. It's in the upper echelon of crazy fun you can have with music in less than 2 minutes. If you're not going to listen to album, at least give Effigy a listen.
With that madness over, the album takes a bit of a turn with Worms Will Feed. A much slower song, it's still brutal in its own way. If you're an kind of fan of heavy music, you will not be able to listen to this track without headbanging uncontrollably. I would even say with RECKLESS ABANDON. The riff on this song is just so infectious, you cannot help but succumb to it like some kind of mindless zombie. I don't care if that sounded lame, you'll understand when you give it a listen.
The album then moves into Wishing Well, which again is a bit slower in the tempo department, though it does go into a few moments of paradiddling, riffing and noodling frenzy.
Damages, Losing Battle, Dead Beat all have some very contagious riffs and beats to groove to. In a way I feel like these songs are the jazzier side of the album. Where the first 4 tracks were just madness, and the next 3 were off-beat mosh tracks, this batch is more elaborate in some way...
Slave Driver is a lot of fun, with a very catchy shouted chorus type deal. Yet another song on this album that I would destroy myself in the mosh for.
Cruel Bloom is a pretty jarring shift from Slave Driver, with a very mellow piano kicking off the track. The vocalist on this song is none other than Steve von Till of Neurosis fame. Von Till has the most badass voice out there, just listen to any Neurosis album and you'll see. Anyway, Cruel Bloom is a very haunting ... well, I'd call it a power ballad.
The album closes with Wretched World, which is another mellow track weighing in at 7:10. It's a pretty awesome way to end the album really, when you consider how much energy they poured into the earlier tracks. The album is very a roller-coaster ride until the end where it lets you down gently... and you walk away with weak legs and headspin. Some metal purists might call these last 2 songs fizzers or something... But I think they were a great choice, and another example of the awesome talent the band has. It's also a credit to Kurt Ballou, the guitarist who melted your face throughout the album, as he also produced this work of art.
Go get this album. 'Nuff said.
Study…
Well, after some deliberation I have decided to get back on the horse, so to speak, with my tertiary study. Through the miracle of the interwebs and an organization called Open Universities Australia (OUA), I've been studying a degree for the past 8 years on and off.
The undergraduate course I'm studying - one Bachelor of Technology (majoring in Computing Studies), is only supposed to take 3 years fulltime. Unfortunately my study-ethic was pretty terrible when I was younger, so I'm currently only about half way through. To be fair, I did start studying when I was 13 and I guess I just never took my studies too seriously; lack of maturity and focus etc etc. You understand, right? Right?...
Well, anyway. I've picked up two units to study this Study Period (the OUA equivalent of a semester - except they cram 4 in one year for max profitz), which is going to be interesting because apparently this workload is equivalent to a standard fulltime uni workload. As it happens, I'm also working full-time right now, so the next few months will definitely not leave me for want of stimulation or entertainment.
The two units I'm studying are CPT223 - Scripting Language Programming and CPT373 - Web Development Technologies. My fulltime job pretty much completely consists of writing rich AJAX web application stuff in PHP/JS, so I'm hoping these units won't pose too much of a threat. That being said though, I haven't worked with Python or Perl at all, ever. I have worked with other scripting languages however, such as Small and LUA. I've also had relatively little exposure to .NET, although again I worked on decent sized project that consisted of a C# web service backend and VB/C# .NET frontend applications.
Supposedly, a unit should be given at least 10 hours of study a week. So if I'm doing 2 units, 20 hours - I'm theoretically going to need to study about 3 hours a day to keep up with the pace. Given that I'm working 8 hours a day, I'm somewhat banking on the hope that because I'm already pretty familiar with the technologies and principles being covered in these units, my workload should be around half to 2/3 of what it should normally be. I think I can swing 1.5 - 2 hours a day on study, no sweat.
Even if this doesn't end up being the case, my employment arrangement is in reality a 80% salary deal, although I'm currently working a full 5 days there as there's a fair bit going on. If my study load became too heavy, there is the possibility that I could scale back a bit to 4 days a week, or even 4.5 days a week (work 5 days every second week).
Study begins in earnest on 1st June! Wish me luck!
Fixed-height container/variable-height content Vertical Alignment using CSS
Whew. The title is a bit long-winded eh?
This short blog post highlights how to vertically center variable-height block-level content inside a fixed height container, in a cross-browser, (mostly) standards compliant manner.
I've lost count of how many times I've needed to do this. Seriously. For example, you may have a block of text, or an image or two that need to sit nicely in a container you've allocated for it. For quite a while now, all standards-compliant browsers have had support for the display: table CSS declaration, which makes vertical alignment a snap. Unfortunately though, Internet Explorer is way behind in the game, with both IE6+7 not supporting this declaration. There is hope however!
I have stumbled across the following page a few times now, it's the best resource I've found on how to overcome this problem.
http://www.jakpsatweb.cz/css/css-vertical-center-solution.html
I've adapted this solution into a set of 2 CSS files that I now use when I need to vertically center something.
valign.css
div.valignContainer {
display: table;
overflow: hidden;
}
div.valignMiddle {
display: table-cell;
vertical-align: middle;
}
valign_ie.css
div.valignContainer {
position: relative;
}
div.valignMiddle {
position: absolute;
top: 50%;
}
div.valignInner {
position: relative;
top: -50%;
}
Include it in the page like so:
<link rel="stylesheet" href="valign.css" type="text/css"/> <!--[if lte IE 7]> <link rel="stylesheet" href="valign_ie.css" type="text/css"/> <![endif]-->
To use this solution, let's say you currently had markup like so:
<div id="myContainerThatSpecifiesAppearanceAndDimensions">
<div id="myContentThatNeedsTobeVerticallyCentered">
Content that should be vertically centered!
</div>
</div>
You would change it to the following:
<div id="myContainerThatSpecifiesAppearanceAndDimensions" class="valignContainer">
<div class="valignMiddle">
<div id="myContentThatNeedsTobeVerticallyCentered" class="valignInner">
Content that should be vertically centered!
</div>
</div>
</div>
That's all, folks!

