views:

281

answers:

0

I use the following python function to mark an item as read in google reader, but it always returns error HTTPErrors: HTTP 401: Unauthorized:

def mark_as_read(SID, entryid):  
    token = get_token(SID)  
    mark_as_read_url = 'http://www.google.com/reader/api/0/edit-tag'  
    header = {'Content-type': 'application/x-www-form-urlencoded'}  
    post_data = urllib.urlencode({ 'i': entryid, 'a': 'user/-/state/com.google/read', 'ac': 'edit', 'T': token })  
    request = urllib2.Request(mark_as_read_url, post_data, header)  
    f = urllib2.urlopen(request)  
    result = f.read()

Other functions are successfully retrieving feeds and entries , so it's not something basic like a wrong username or password. I've read that urlencoding is required, so I've done that. A sample entryid looks like this: tag:google.com,2005:reader/item/f66ad0fb64f56a22

What am I doing wrong?