如何使用 google reader API 标记已读项目?
我一直在为谷歌阅读器开发一个客户端。一切工作正常,除了我无法编辑条目以添加“加星标”和“已读”等标签。 code.google.com/p/pyrfeed/wiki/GoogleReaderAPI 和 www.niallkennedy.com/blog/2005/12/google-reader-api.html 上的说明似乎已过时。更奇怪的是,我一直在检查谷歌本身使用的 POST 数据并尝试准确复制它,但我仍然无法让它工作。例如,我最接近的是 http://www.google .com/reader/api/0/edit-tag,包含 POST 数据 a=/user/-/state/com.google/starred&async=true&s=[feed]&i=[item] &T=[token]
这似乎正是谷歌本身所做的,但我总是得到“无效的流名称”。有什么建议吗?
I've been working on a client for google reader. Everything works fine, except that I can't edit entries to add tags such as "starred" and "read." The instructions at code.google.com/p/pyrfeed/wiki/GoogleReaderAPI and www.niallkennedy.com/blog/2005/12/google-reader-api.html seem to be outdated. What's more odd is that I've been inspecting the POST data that google itself uses and attempting to replicate it exactly, but I still can't get it to work. The closest I've come is, for example, http://www.google.com/reader/api/0/edit-tag with POST data a=/user/-/state/com.google/starred&async=true&s=[feed]&i=[item]&T=[token]
This seems to be exactly what google itself does, but I lways get back "Invalid Stream Name." Any advice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有给你一个明确的答案,但我在 API api/0/edit-tag 方面也遇到了一些麻烦,并设法让它们正常工作。
我已经在使用 API 的其他部分,没有任何问题(api/0/stream/items/ids、api/0/unread-count),但是这个部分工作起来并不那么容易。
一段时间后,我重新开始检查他们的网络前端(使用 Chrome 开发工具)发送到 Google Reader 的请求,并制作了一个硬编码示例(您可以使用此代码,只需更改您自己的 id 和流) - 请注意它们具有所有必需的前缀:feed/(用于流)和 tag:google.com,2005:reader/item/(用于 id)。
下面是我将流中的特定项目标记为已读的最终代码(translateToItemAtomId 方法用于将 api/0/stream/items/ids 返回的长整数 id 转换为该 API 接受的原子 xml id):
您可能需要一些额外的代码(基于 http ://www.chrisdadswell.co.uk/android-coding-example-authenticating-clientlogin-google-reader-api/):
希望这有帮助!
I don't have a definitive answer for you, but I was also having some trouble with the API api/0/edit-tag and managed to get them working.
I was already using other parts of the API without any trouble (api/0/stream/items/ids, api/0/unread-count), but this one was not working as easily.
After a while, I started over by inspecting the requests sent to Google Reader by their web frontend (using Chrome dev tools), and made an hardcoded example (you can use this code and you just need to change the ids and stream for you own - just be careful that they have all the needed prefixes: feed/ for stream, and tag:google.com,2005:reader/item/ for id).
Here is my final code for marking a specific item from a stream as read (the translateToItemAtomId method is used for converting the long integer ids as returned by api/0/stream/items/ids into the atom xml ids accepted by this API):
Some extra code you may need (based on http://www.chrisdadswell.co.uk/android-coding-example-authenticating-clientlogin-google-reader-api/):
Hope this helps!