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?
It seems you are missing the authentication header:
header = {
'Content-type': 'application/x-www-form-urlencoded',
'Authorization': 'GoogleLogin auth=YOUR_AUTH_TOKEN'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With