brad's life - AddressBooker & exporting my Facebook Phonebook [entries|archive|friends|userinfo]
Brad Fitzpatrick

[ website | bradfitz.com ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

AddressBooker & exporting my Facebook Phonebook [Nov. 30th, 2008|09:25 pm]
Previous Entry Share Next Entry
[Tags|, , , ]

This 4-day weekend was awesome for catching up on personal hacking projects. In addition to adding IPv6 support to Perlbal and hacking on my interactive shadow/art wall more, I also worked on a little address book management tool, AddressBooker [source here].

Basically AddressBooker takes a POST of contacts data in JSON form, and does stuff with it, where "stuff" is currently limited to merging it into your Google Contacts. (GMail, Android, etc) This was my experiment in learning GData, AuthSub, and App Engine a bit more.

Anyway, I then wanted to get my Facebook Phonebook exported to my Google Contacts, so it'd sync to my Android phone. I didn't see an export option in Facebook (maybe I missed it?), so I wrote a little GreaseMonkey script instead to automate the whole process:

http://bradfitz.com/greasemonkey/facebook_phonebook_export.user.js

If you have Firefox and GreaseMonkey, then click the above link and it'll ask if you want to install it. Install it, then go to your Facebook Phonebook (sorry, no permalink to it), then go into Tools > GreaseMonkey > User Script Commands... > and you'll see Export Facebook Phonebook. That'll then page through your phone book (you should probably start on page 1: it's kinda flaky) and extract the data, and then POST it to AddressBooker for you, which will then guide you through merging it into your Google Contacts.

Enjoy!

(And keep in mind I barely know browser stuff or Greasemonkey or Python or App Engine or GData, so patches welcome!... brad@danga.com, or Github)

Update 2009-05-09: Updated the JavaScript to work with Facebook's new layout.

Update 2010-06-06: Facebook's markup changed again, but I'm too lazy to go update the script. Patches welcome.
Link

Comments:
[User Picture]From: davidglasser
2008-12-01 07:02 pm (UTC)

(Link)

Apparently I have too many Google contacts already:

Traceback (most recent call last):
  File "/base/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 499, in __call__
    handler.get(*groups)
  File "/base/data/home/apps/addressbooker/1.329670894575284061/addressbooker.py", line 345, in get
    self.ProcessMerge(method='GET')
  File "/base/data/home/apps/addressbooker/1.329670894575284061/addressbooker.py", line 431, in ProcessMerge
    feed = client.Get(full_feed_url, converter=gdata.contacts.ContactsFeedFromString)
  File "/base/data/home/apps/addressbooker/1.329670894575284061/gdata/service.py", line 700, in Get
    headers=extra_headers)
  File "/base/data/home/apps/addressbooker/1.329670894575284061/atom/service.py", line 176, in request
    data=data, headers=all_headers)
  File "/base/data/home/apps/addressbooker/1.329670894575284061/gdata/auth.py", line 456, in perform_request
    return http_client.request(operation, url, data=data, headers=headers)
  File "/base/data/home/apps/addressbooker/1.329670894575284061/gdata/alt/appengine.py", line 144, in request
    method=method, headers=all_headers, follow_redirects=False))
  File "/base/python_lib/versions/1/google/appengine/api/urlfetch.py", line 278, in fetch
    raise ResponseTooLargeError(result)
ResponseTooLargeError
(Replies frozen) (Parent) (Thread)
[User Picture]From: brad
2008-12-01 07:08 pm (UTC)

(Link)

I was worried about that. Frustrating App Engine limits.

Okay, I'll have to fix that next time I get some free time.
(Replies frozen) (Parent) (Thread)
From: blog.grasstodiesel.com
2008-12-11 10:36 pm (UTC)

Great idea!

(Link)

I've been looking for an app like this, but sadly I get the same error as I have too many contacts I guess?

Anyway, if you feel inspired to fix this, it would be much appreciated...
(Replies frozen) (Parent) (Thread)
From: (Anonymous)
2008-12-13 11:01 pm (UTC)

Too many contacts

(Link)

Same problem
(Replies frozen) (Parent) (Thread)
From: (Anonymous)
2008-12-31 06:49 pm (UTC)

ditto

(Link)

Yeah, I'm running into the same problem... So close!!!
(Replies frozen) (Parent) (Thread)