Gathering Facebook Identities from Email

Looking at the announcement of the Facebook Graph API from Facebook F8 it seems like it will be a little easier to work with the Facebook system.

In Raindrop we already have some integration with Facebook in order to identify emails coming from the Facebook system and help you filter them out. But there is a lot more that can be done to help keep your email, Facebook, and other contacts in a cohesive form.

So here’s a quick code example written in Python to grab Facebook identities from emails sent by Facebook. This could be used to gather Facebook identities and then possibly merge those with twitter and email contacts.

First we need to import a couple things.

import email, json, urllib2

Then we’ll need to grab an email message.  I used Thunderbird to save a Facebook notification email message as an EML file locally, I called that file ‘facebook.eml’ as you can see below.

msg = email.message_from_file(open('facebook.eml'))

Now we have a parsed email message msg object and we want to look for the X-Facebook-Notify header in the email so we can extract what happened.

fb_notifiy = [tuple(t.strip().split("=")) for t in \
              msg.get('X-Facebook-Notify').split(";")]

The object fb_notify contains tuples of information about the type of notification.  Here is an example of an object you might see.

[('event_wall',),
 ('eid', '14102494623'),
 ('from', '21602578'),
 ('mailid', '12bf28cG149a112G63016bG21') ]

Using fb_notify we’ll do a really simple grab of the from attribute because that is what is going to be publicly available from the Facebook Graph.

from_identity = json.load(urllib2.urlopen("http://graph.facebook.com/%s" % fb_notify[2][1]))

Here’s an example from_identity object:

{u'first_name': u'Bryan',
 u'last_name': u'Clark',
 u'id': u'21602578',
 u'name': u'Bryan Clark' }

The from_identity can be used to more clearly identify who Facebook is sending this notification on behalf of and we could try merging this Facebook identity with other identities we already have in our contacts.

I saved all this code into this gist if you want to take a look at it in code only form with syntax highlighting.

Raindrop

Raindrop Shadow Logo

Today Mozilla Messaging released the Raindrop project

Raindrop is an experiment in the design of a new messaging platform in the open.

What I like most about Raindrop is our process.  We started with some simple designs, created a couple iterations and now we’ve opened up the whole process to share.  This isn’t another email client or a twitter client, we have been designing for the way people communicate on the web today.  And we’re looking to make it awesome.

If you’re a developer or just have lots of patience you could grab the source code, follow the instructions and get raindrop up and running.  But that’s not what we’re launching, we’re launching the next version, the one that we design and develop in the open.  Read that again, there is no download. :)

Design

Starting today, new raindrop designs will be uploaded into the Raindrop Design flickr group for discussion and review.  As designs are ready to be implemented we’ll be blogging about them in the Raindrop Design Blog.

Develop

Discussion of code and extension development takes place on the Raindrop Development Google Group.  We’re currently built on CouchDB, Python, and JavaScript(if you’re trying to get raindrop up and running make sure you read the INSTALL doc carefully)

Extend

From the ground up Raindrop was built as a set of extensions on top of extensions.  This architecture was a design choice so that others could easily continue extend on top of our work.

There are places to add Data Miners which can search messages for regular expressions and User Interface Extensions which can modify the layout and design of messages presented.

Check out James’ video on Raindrop Software Components for more on the extensions system.

aboot

This is the blog personality of Bryan Clark. I'm a designer in a world of open source. This blog reflects mostly writing about Design, Open Source, Economics, Beer, Wine, and Dogs. There's more information about me on this site or you can contact me directly at clarkbw@gmail.com.

scategories