Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用google reader api(使用python)将项目标记为已读_Python_Google Reader - Fatal编程技术网

如何使用google reader api(使用python)将项目标记为已读

如何使用google reader api(使用python)将项目标记为已读,python,google-reader,Python,Google Reader,我使用以下python函数将项目标记为在google reader中读取,但它始终返回错误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': 'applic

我使用以下python函数将项目标记为在google reader中读取,但它始终返回错误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() def标记为读取(SID,entryid): 令牌=获取令牌(SID) 标记为已读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(将\标记为\读取\ url,发布\数据,标题) f=urllib2.urlopen(请求) 结果=f.read() 其他函数正在成功地检索提要和条目,因此这不是像错误的用户名或密码这样的基本问题。我已经读到urlencoding是必需的,所以我已经这样做了。示例entryid如下所示:tag:google.com,2005:reader/item/f66ad0fb64f56a22


我做错了什么?

当我将其与我在Firefox中发出的请求(使用liveheaders进行检查)进行比较时,它看起来还行。我只有额外的参数

async=true
sync=true
s=feed/http://feeds.feedburner.com/37signals/beM
在用户中,
-
的位置上有一个长id

因此,您可以尝试添加两个sync参数,添加s参数,并为
-
填充一个id


关于您正在执行的URL编码,这似乎是可以的。

您似乎缺少身份验证标头:

header = {
    'Content-type': 'application/x-www-form-urlencoded',
    'Authorization': 'GoogleLogin auth=YOUR_AUTH_TOKEN'
}

这是一篇文章,您使用的成功请求示例听起来像GET。你还有其他成功的帖子吗?也许这两个API之间有一些差异,您还没有弄清楚?附言:Neds团结起来!我使用Perl以同样的方式访问GoogleReader,除了更改项目的状态(标记为read、Starting等),其他一切都对我有好处。在Reader中列出项目对我来说很好。。。我有一种感觉,这可能是在谷歌端的东西,或者可能是非官方的API不是最新的关于如何将项目标记为已读?有更新吗。我还需要在python应用程序中实现mark as read。谢谢