litl/rauth — pull request #47 by marekrei (2012-10-06 18:44:51+00:00)
Title: Checking that the LinkedIn update has currentShare field

I looked into why I was getting an error with the linkedin-updates.py example. Apparently the API reponse from LinkedIn doesn't always contain the currentShare field that is used in the example. This is an update from my stream:

{'updateKey': 'key-removed-just-in-case', 'isCommentable': True, 'isLiked': False, 'timestamp': 1349354311405L, 'numLikes': 0, 'isLikable': True, 'updateType': 'SHAR', 'updateContent': {'person': {'lastName': 'private', 'id': 'private', 'firstName': 'private'}}, 'updateComments': {'_total': 0}},

And it was causing the error:

Traceback (most recent call last):
File "linkedin-updates.py", line 41, in
current_share = update['updateContent']['person']['currentShare']
KeyError: 'currentShare'

The code now checks whether the field exists and prints the update key if it doesn't. I considered not printing anything, but that messes up the numbering.
Also added myself as an author. :)

Cheers