简体   繁体   English

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

[英]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.

相关问题 如何在解析时使用 gmail api 将邮件标记为已读? - How to mark messages as read using gmail api as i parse? Python exchangelib - 将项目标记为已读 - Python exchangelib - mark item as read 使用for循环,如何获得最高标记并在python中显示? - Using for loop, how do I get the highest mark and display in python? 如何使用 Python 从 TOML 文件中读取 Google API 凭据? - How do I read Google API credentials from a TOML file with Python? Podio:如何为我刚刚使用Python 3的API创建的项目添加注释? - Podio: How do I add a comment to an item I just created using the API for Python 3? 使用Python和SQLite,如何将数据库中的项读入变量? - With Python and SQLite, how do i read an item from the database into a variable? 如何使用 google api 和 python 在 google docs 中打开文件? - How do I open a file in google docs using google api and python? 如何使用 Google 云端硬盘 API v3 向 Python 中的共享文件夹进行可续传上传? - How do I do a resumable upload to a shared folder in Python using Google Drive API v3? 如何在不登录的情况下使用密钥在python中阅读谷歌电子表格? - How do I read a google spreadsheet in python using key, without signing in? 如何使用 python 使用驱动器 API 将文件上传到谷歌驱动器? - How do I upload file to google drive using drive API using python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM