Validating Facebook Connect API cookies in perl

July 29th, 2010 by Antti Vähäkotamäki

I didn’t find a sample code for validating the Facebook Connect API cookies in perl from Google so here is one. The CGI::Cookie interface is a bit tricky to use with the Facebook cookie parsing as it wants to split the cookie contents automatically on each ampersand, but here is how we translated the given sample PHP code to perl:

use CGI::Cookie;
use URI;
use Digest::MD5;

my $app_id = "136913766343238";
my $secret = "dbct84ca3d1fbs44428r02bdbag9193e";
my $cookie_header = $ENV{COOKIE};

my %cookies = CGI::Cookie->parse( $cookie_header );
my $cookie_object = $cookies{'fbs_' . $app_id};

die unless $cookie_object;

my $cookie = join "&", $cookie_object->value;
$cookie =~ s/^[\\"]*(.*?)[\\"]*$/$1/;

my $uri = URI->new("", "http");
$uri->query( $cookie );
my %params = $uri->query_form;
my $sig = delete $params{sig};
my $payload = join '', map { $_ .'='. $params{$_} } sort keys %params;

die unless Digest::MD5::md5_hex( $payload . $secret ) eq $sig;

my $valid_facebook_user_id = $params{uid};

Splitting the query parameters would have been pretty easy to do with a regexp but as the sample PHP code uses it’s query parser, I thought using a valid query parser from URI would be a safe and easy bet.

Aggregating online presence

May 31st, 2009 by Antti Vähäkotamäki

As a part of something I just humoristically named “the communications review and growth initiative” at work, I registered into a couple of new services and my online presence should, as of today, be aggregated from my public blogs to FriendFeed, from FriendFeed to Twitter and from Twitter to Facebook.

If I find myself cooking up a presence on del.icio.us, Digg, Flickr or Youtube, they will be added to FriendFeed but for now I don’t feel like I would have much to offer on the Photo / Video / cool link sharing front as they are not part of my daily routine. Starting microblogging in Twitter feels like a big enough step for this week.

Now I just hope the aggregation works as I understood it would :)

Our media assistant trainee needs to get from 0 to 100 on video production, pronto. Any suggestions?

December 10th, 2008 by Antti Vähäkotamäki

Saija is interested in video production and is planning to film some interviews and short documentaries during her time as a trainee here at Dicole. She has done some amateur filming but considers herself a beginner. She wants to know good resources and helpful people to get started on video production. I’d imagine she will mostly be using our HD cam and iMovie HD on her Mac but good suggestions and learning resources are warmly welcome :) (myös suomeksi :) )

Opening the gates to a new religion

December 4th, 2008 by Antti Vähäkotamäki

I picked up my new shiny MacBook today. I’m also contemplating on building an altar for Steve, so that I could pray for a good user experience.

Connectivism in the grassroots of ITK 07

April 19th, 2007 by Antti Vähäkotamäki

I’m in ITK 07 conference and Karsten Wolf just gave a good keynote presentation. I think it brought together most of the relevant concepts that I would like to see all ITK participants grasping as the common basis for communication in other presentations.

I’m writing this blog entry briefly just to point out that while Wolf mentioned that the answer to the question “What is the role of collaborating and sharing in succesfull online learning?” is still largely unknown and under research, there exists a paradigm called connectivism which in my opinnion tries to answer to this question from a better point of view than could be easily possible using constructivism (or one of its various extensions) as a basis of thinking.

I’d also add on the subject that while Wolf pointed out that changes in the internet enable constructivistic learning to emerge from the grassroots, this has already been true from the beginning of the internet. The social transformation of the web (to which some refer as Web 2.0) does also enhance the possibilities for constructivistic learning but in my opinnion it enhances far more the ways of handling information and knowledge which connectivism touches on.

BTW. As this is a social conference, I’d be very interested if Wolf himself has something to add to this – so please join the conversation Karsten!

A blossoming nugget

March 31st, 2007 by Antti Vähäkotamäki

I haven’t been out in bars much for a long time since I have usually prioritized other activities over the odor of cigarettes, swarms of drunken finns and music so loud that you can’t really make up a good conversation. Yesterday Kim talked me over to spending the evening in Valter Cafe which to my lovely surprise seemed like an enjoyable non-smoking venue and after a couple of GTs I drifted into making acquintance with a friendly couple at a table next to ours.

From our conversation I picked up a golden nugget which seemed to resonate exceptionally well with my own gut feeling but in which I hadn’t put that much thought before and certainly couldn’t put into words as eloquently: In order to achieve the most in life it is not only important to grow as a person but to help others around you to blossom. (translated freely from finnish)

I’d like to believe that the gut feeling I have had about this has led me to help many great and likeminded people achieve more than they would have without me, but putting this feeling in such a concrete form will surely help me put even more attention to empowering others to drive forward worthy goals. And what is even better, I am now more able to encourage others to do the same!

For this and other enlightening insights that you shared with me tonight I would like to hearthly thank you Kalle, and if you read this, please drop me a comment or an e-mail with your blog/website address so that I can properly credit you with a link :)

Letting loose

March 30th, 2007 by Antti Vähäkotamäki

I am one of those people who like to have the feeling that they are going into the right direction. When somebody makes a decission which affects me and I feel that from my point of view this decission isn’t the right one, I usually engage quite eagerly in to a conversation about the views behind the given decission and why I would have made an another decission.

Sometimes I end up changing the decission and sometimes I end up learning to see the situation from a different perspective which jusfies the decission. To me this kind of a way to debate decisisons sounded at first like a good way to approach decission making in a small company like ours but after some frustrating experiences it has become more clear to me what is probably the cause of the overly hierarchical government model which enterprises of yesterday have drifted to (in my opinnion as a bit overly aggressive countermeasure): Converging different points of view takes a lot of time and effort and doesn’t often lead to a solution which is so much better that it would justify the effort.

As it is an integral part of my nature to question things and delve deeper into subjects it is quite challenging to learn to live with decissions that I don’t understand – even if they are only small ones. However it is a challenge that I feel that I must overcome in time to become a better colleague and also a better leader. This doesn’t mean that I will never again question any decissions but I will try to evaluate the possible outcomes of the process before giving up to my urge to understand, help others understand and ultimately set things right.

In the end it all comes to what we were talking the other day at lunch with Tommi: Maybe managing a company isn’t all that different from managing your personal life – in order to gain the most there are many things that are better to be left unmanaged and just trust that they can’t turn out so bad that the situation couldn’t be fixed anymore.

Language nuances

December 2nd, 2006 by Antti Vähäkotamäki

Today I have been watching some old videos made by an interesting person I stumbled upon yesterday, Tom Guarriello who also writes the TrueTalk Blog. While watching this video which touches business jargon in a humoristic way and hearing Tom list some words he thinks are used mainly to obfuscate what is really being said, I was reminded of the thoughts I have had on the subject of language nuances.

What really struck me in the video was that most the terms Tom listed sounded really natural to me. That means that I myself have formed in my mind a clear representation of the terms and thus can quickly form thought structures based on those words. Since I have had quite a lot of contact with texts and speeches that use those words, I have become more and more assured from the contexts that the words really convey the same meaning that I understand from them.

And then comes Tom, telling me that these words are really used mainly to obfuscate.

Now, I am a strong believer in subjective realities, meaning that all information we gather from the world is strongly influenced by our own minds. Since our minds have developed independently (although most of us sharing a relatively similiar culture), it is very natural to end up in situations where people end up having a very different take on a subject based on the same information. Thus it would be normal to just handle this discrepancy by thinking that it is natural for people to have slightly different views and adjust my personal view slightly towards Tom’s so that it might fit closer to the average perception that would help me communicate with people better.

There is just a slight problem: Tom is a native english speaker who apparently has made a career for himself out of conversing while I am a non-native speaker whose perception of english is mainly built on reading and listening things that are essentially monologues.

So clearly Tom has a much better understanding of the nuances these words carry in the real life, which naturally puts a lot of pressure on me to shift my views more than normally towards his views. But the question is, should it really?

I am not disputing the fact that I am a non-native speaker and thus have a much worse command of the language than Tom, but what I would like to point out is that the world is full of people like me in this matter. Internet and globalized world is bridging together masses of people who are non-native english speakers, have limited possibilities to converse with native speakers and thus have very little chance of gathering most of the nuances of the language. Yet still these people have to use english as their medium of communication with each other and also native speakers.

Is it reasonable to expect non-native speakers to try to understand words with all the nuances that native speakers generally do or will becoming the global business language be the demise of these little nuances? Time will tell but I think we are still going to be picking the low hanging fruits for a long time since the phrase does have a clear logical justification, even if we as humans often fail to understand the full implications of our planned actions.

Geriatrical revolution?

August 16th, 2006 by Antti Vähäkotamäki

I don’t follow Youtube as a community very closely but I go there quite regularily to check out the new videos from some really entertaining people and thus usually get informed if something big is happening.

So during the last week a new channel has jumped to being the seconds most subscribed channel (all time) in Youtube and at this rate is going to end up at the top very soon.

So what is this phenomenon which tops all the people who have been posting quality entertainment for months? It’s a 78 year old man from UK who is telling his life story in short videos.

I think that this is quite remarkable as it shows us a prime example of how technology can enable the elderly to be a valuable part of the modern society, just like they were before when grandparents used to live with the family. This also shows that there still exists a huge interest for what the older generations have to say if only the message can be delivered in a way that it fits into the schedule of a modern, asynchronously living person.

I think that given this kind of examples along with the ones like gaming grandma, older people are going to start to realize the benefits they can achieve through technology and get more incentive for facing their fears. I have always thought that we will achieve the big digital village which spans all generations only after the current computer savvy generations reach their elderhood, but maybe we will get there much sooner than I expected!

Unconference aktivoi

April 7th, 2006 by Antti Vähäkotamäki

Päivä alkaa olla päätöksessä ja on aika purkaa päivän hienoin kokemus. Vaikka katsomani estykset olivatkin erinomaisia ja mielenkiintoisia, rakastaa sitä kai kuitenkin omien ajatustensa pallottelemista eniten :) . ITK on nimittäin blogien lisäksi kokeillut konferenssin rajoja myös muilla rintamilla ja alakerrassa Dave Winerin “Unconference”-hengessä toimiville tapaamisille varatussa huoneessa voi käydä ripustamassa seinälle kokouskutsun haluamansa aihealueen keskusteluun, jotta aiheesta kiinostuneet tietävät saapua paikalle vaihtamaan ajatuksiaan tiettyyn kellonaikaan.

Kyseessä on siis vapaamuotoisesta aiheesta järjestetty ex-tempore keskustelu-workshop, jossa puheenjohtajana toimii kokouksen kokoonkutsuja. Meillä oli tällainen tapaaminen blogien käytöstä koulutuksen kentällä ja aihe houkutteli paikalle kymmenisen henkeä hyvin vähäisellä varoitusajalla. Väkea oli koko ajan juuri sopivasti niin, että välillä kerkesi sanomaan oman sanansa ja välillä pohtimaan muiden näkemyksiä ja mielipiteitä.

Keskustelun hedelminä totesimme mm. blogit niin yksinkertaisiksi ja luonteviksi, että ne on helppo ottaa käyttöön, mutta myös niin monipuoliseksi, että niitä voidaan käyttää mitä erilaisempiin tarkoituksiin aina sisällönhallinnasta sosiaalisen verkoston keräämiseen. Mutta näitä mielenkiintoisia ajatuksia enemmän minua mietityttää se, oliko keskustelumme onnistuminen vain silkka onnenkantamoinen?

Voin hyvin kuvitella, että tällainen keskustelutilaisuus ei kerää kylliksi osallistujia tai kerää niitä liikaa niin, että keskustelun sijasta päädytään pääosin seuraamaan vierestä. Jos ajatusta lähtisi kehittämään pidemmälle tulevia konferensseja varten, tulisi näihin kahteen ongelmaan varautua, jotta taataan mahdollisimman monelle oikeus siihen hienoon kokemukseen, jonka me tänään jaoimme.

Väen paljous voitaisiin mielestäni helposti ratkaista jakamalla halukkaat useampaan sopivan kokoiseen ryhmään ja nimittämällä tarvittava määrä varapuheenjohtajia lennosta. Tämä kuitenkin vaatisi sen, että tiloja kokoontumiselle on varalla enemmän kuin yksi. ITK:ssa tapaamisille varatun huoneen vieressä on onneksi muistaakseni yksi vapaassa käytössä oleva huone, johon voimme esimerkiksi perjantaina järjestettävässä uudessa “Unconference”-tapaamisessa (josta puheenjohtajana toimiva Jere Majava juuri blogissaan kirjoittikin) levittäytyä mikäli väkeä saapuu paikalle sankoin joukoin.

Väen vähyyteen onkin ehkä vähemmän keinoja vaikuttaa ja voisikin tuntua vähän orvolta ehdottaa tapaamista jonkin marginaalisen kiinnostuksen kohteen tiimoilta mikäli ei tiedä yhtään onko asiasta kiinnostuneita koko konferenssissa. Marginaalisempienkin aiheiden asiantuntijoita löytyisi varmasti helpommin mikäli tällaiset tapaamiset olisi leivottu sisään konferenssiin ja niiden etsimiseen ja järjestämiseen opastettaisiin järjestelmällisesti, mutta silti jäisi aina niitä aiheita, joihin ei vain löyty kynnelle kykeneviä osallistujia. Tällaiseen tilanteeseen voisi auttaa esimerkiksi jonkinlainen varausjärjestelmä, jolla voisi etukäteen ilmoittaa saapuvansa tilaisuuteen ja mikäli 5 minuuttia ennen tapaamista ei ole kylliksi ilmoittautuneita osallistujia, voitaisiin tapaaminen peruuttaa ja osallistujat voisivat hypätä muihin mielenkiintoisiin keskusteluihin, jotka järjestetään samaan aikaan.

Tällaisen rittävän suuren keskusteluja etsivien aktiivisten asiantuntijoiden ekosysteemin syntymiseen tarvittaisiin kuitenkin ehkä ihan oma varattu aikansa tai peräti oma tilaisuutensa, sillä konferenssissa aikaa on todistetusti itse kullakin kovin vähän uhrattavaksi, sillä mielenkiintoisia esityksiä puskee jo nyt joka nurkasta toistensa kanssa päällekkäin. Vai pitäisikö sittenkin vain antaa lopulta viidakon lakien mukaan mielenkiintoisempien tilaisuuksien voittaa? :)