Sunday, January 23, 2011

Facebook API calls with Javascript

The social networking app I'm writing with my would be mentor requires integration with facebook.  Given the ubiquity of javascript, I decided, what better way to integrate with facebook than through their Javascript SDK?


While testing a simple case I encountered a frustrating error where facebook api calls seemed to simply stop functioning -- no init's, login information, graph api calls, no nothing.  There wasn't even an unsuccessful login session object returned.  And it seemed as though nothing had changed.  I was ready to blame facebook, but after a little bit more debugging I discovered the cause:

<pic to come>

All facebook javascript sdk calls with a specific app ID must be made from the same domain as the canvas url.  This is very possibly a manifestation of the same origin policy, a rather stringent security necessity for Javascript.  In any event, with that discovery, I was able to continue testing.  However finding the cause of the bug was quite difficult, since facebook's own error response for the issue was virtually nonexistent, and many forums confused the cause of the lack of function with erratic facebook code state.  Ultimately nothing beats personal debugging

Finest Beating of My Life .. So far

You seen his portrait downstairs?  

Yesterday I took my green belt test for Krav Maga.  It was grueling through techniques encompassing kick defenses, punch defenses, reactions to hair grabs, bear hugs, reverse headlocks.  I had already gone through two and a half hours and 2 t shirts ... and then we got to the sparring portion and things just got sadistic.

The dreaded sparring portion of the green belt test is infamous for absolutely beating the crap out of everyone who takes it, and I can personally attest to this.  I'd been supplementing my usual krav maga classes with fight classes for a few months and luckily that kept me from being reduced to pure pulp. For an hour and what seemed like forever, I was rotated in and out of a shark tank and had to stand and fight people well past the point of my endurance.  I think I literally collapsed after my turn in the shark tank, but then had to pull myself together for the rest of the test.  More than once I thought of how obscene it was that I was paying for this abuse.  But now that I've had a little bit of time to think about it, I think I see the value of such abuse: if you can make it through something that tough, then a lot of things in life are that much easier.  Toughness in people is a quality I really respect and so if I can summon it in myself, it boosts my self respect as well.

At the very least, the next time I get hit, instead of thinking 'ow', I can think 'oh heck, this isn't as bad as my green belt test'

oh yeah, and hopefully I passed.  I still haven't found out