[英]How do I mark an item as read with google reader api (using python)
I use the following python function to mark an item as read in google reader, but it always returns error HTTPErrors: HTTP 401: Unauthorized: 我使用以下python函数将项目标记为在谷歌阅读器中读取,但它总是返回错误HTTPErrors:HTTP 401:未经授权:
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.
我已经读过urlencoding是必需的,所以我已经做到了。 A sample entryid looks like this: tag:google.com,2005:reader/item/f66ad0fb64f56a22
示例entryid如下所示: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'
}
When i compare this to the request I'm making in Firefox (inspected with liveheaders), it looks ok. 当我将其与我在Firefox中进行的请求(使用liveheaders进行检查)进行比较时,它看起来没问题。 I only have the extra parameters
我只有额外的参数
async=true
sync=true
s=feed/http://feeds.feedburner.com/37signals/beM
And in the user, on the place of -
there is a long id. 在用户中,在 - 的地方
-
有一个很长的身份。
So you could try adding the two sync parameters, adding the s parameter, and filling in an id for the -
. 所以,你可以尝试添加两个同步参数,增加s参数,并在为一个id灌装
-
With regard to the urlencoding you're doing, that seems to be ok. 关于你正在做的urlencoding,这似乎没问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.