For a reason that will be too long to be explained here, today I wanted to look for one of my old Facebook statuses. Even if it turned out that there are Facebook applications (mystatuses is an example) that allow you to list all of your statuses, the hacker that's in me wanted to do that programmatically.

The following is a very quick and dirty hack, bypassing in an horrible way the issue of authentication and autorization; but it's enough for my purposes.

First of all (this is the dirty part) login to Facebook as yourself and then go to the Graph API reference pages and click on the link beside "Status messages", that should read something like https://graph.facebook.com/367501354973 and copy the value of access_token that will appear in your browser location box (mine is something like 2227470867|2.7n…ovhRVKtvaA).

Now run the following Python script with such value as argument on the command line

from json import loads
from urllib2 import urlopen
from sys import argv

next = 'https://graph.facebook.com/me/statuses?access_token=' + argv[ 1 ]
while next:
        url = urlopen( next )
        data = loads( url.read() )
        for msg in data[ 'data' ]:
                print msg[ 'updated_time' ], msg[ 'message' ]
        try:
                next = data[ 'paging' ][ 'next' ]
        except KeyError:
                next = None

and you'll get all of your data printed on the standard output.

Comments