Downloading photos from Facebook with Linux
Tommy Murphy recently released photograbber, a simple Python/tkinter app that uses the Facebook API to…
1. Find all the photos that you’ve been tagged in and…
2. Download each photo to a chosen directory.
It worked fine for me after I fixed a trivial tkinter bug.
Right now I’m adapting photograbber to download entire albums for me. Here’s the crucial code that requests a collection of “photo” records using Facebook Query Language (FQL):
photos = self.facebook.fql.query("SELECT pid, aid, src_big FROM " \
"photo WHERE pid IN (SELECT pid FROM photo_tag WHERE subject=" + \
str(self.facebook.uid) + ")")
Changing the query to…
"SELECT pid, aid, src_big FROM photo WHERE aid IN (SELECT aid " \ "FROM album WHERE owner IN (SELECT uid FROM user WHERE name=\"" + \ FriendName + "\") AND name=\"" + AlbumName + "\")"
… did the trick. Caveat coder: the album IDs that you see in your browser while surfing Facebook aren’t the same IDs that you should use in your FQL queries. If you slip up, you might receive this misleading message: “FacebookError: Error 600: An unknown error occurred in FQLPhotoTable::get_ids_for_queries: should never have a pid or aid without a uid”
Keep Facebook’s terms of service in mind when interacting with their site – you don’t want a “cease and desist” letter like Vincent Cheung received for his “FaceDown” application.
If all else fails, you might have some luck with a PHP script called “FBCMD” as illustrated here.
I’ll spare you my internet balkanization rant – Fred Vogelstein made the argument far better in the June issue of Wired: Great Wall of Facebook – The Social Network’s Plan to Dominate the Internet – and Keep Google Out.


