使用Google Reader API取消收藏帖子

3 投票
2 回答
876 浏览
提问于 2025-04-15 12:22

有没有人知道怎么通过Google Reader的非官方API来取消文章的星标?

我找到过一个方法,但它不管用:

http://www.niallkennedy.com/blog/2005/12/google-reader-api.html

而且在Python中使用pyrfeed模块也不行,每次都会出现IOError异常。

2 个回答

0

我没有Python的代码(我有Java的),但你遇到的问题和你用的编程语言关系不大。能看到一些代码总是有帮助的,这样你可以了解所有细节。你只需要按照我做的请求,检查我提到的一些细节,看看这是否可能是你的问题。

你可以用这个来取消某个帖子上的星标(注意,这个服务支持同时处理多个项目,如果你需要的话):

        String authToken = getGoogleAuthKey();
    // I use Jsoup for the requests, but you can use anything you
    // like - for jsoup you usually just need to include a jar
    // into your java project
Document doc = Jsoup.connect("http://www.google.com/reader/api/0/edit-tag")
    // this is important for permission - more details on how to get this ahead in the text
    .header("Authorization", _AUTHPARAMS + authToken)
    .data(
             // you don't need the userid, the '-' will suffice
             // "r" means remove. you can also use "a" to add
             // you have lots of other options besides starred. e.g: read
            "r", "user/-/state/com.google/starred",
            "async", "true",
            // the feed, but don't forget the beginning: feed/
            "s", "feed/http://www.gizmodo.com/index.xml",
            // there are 2 id formats, easy to convert - more info ahead in the text
            "i", "tag:google.com,2005:reader/item/1a68fb395bcb6947",
            // another token - this one for allow editing - more details on how to get this ahead in the text
            "T", "//wF1kyvFPIe6JiyITNnMWdA"
    )
    // I also send my API key, but I don't think this is mandatory
    .userAgent("[YOUR_APP_ID_GOES_HERE].apps.googleusercontent.com")
    .timeout(10000)
    // VERY IMPORTANT - don't forget the post! (using get() will not work)
    .post();

你可以在这个其他问题中查看我的回答,里面有更多的实现细节(评论中提到的那些)。

要列出一个订阅源中所有带星标的项目,你可以使用http://www.google.com/reader/api/0/stream/items/ids或者http://www.google.com/reader/atom/user/-/state/com.google/starred。你可以用这些ID来调用上面提到的API来取消星标。

这最后两个链接用起来简单多了。你可以在这些非官方(但结构不错)的资源中查看API的详细信息:http://www.chrisdadswell.co.uk/android-coding-example-authenticating-clientlogin-google-reader-api/http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPIhttp://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2

希望这能帮到你!

1

试试用:

r=user%2F[user ID]%2Fstate%2Fcom.google%2Fstarred 

来代替

a=user%2F[user ID]%2Fstate%2Fcom.google%2Fstarred 

在调用编辑标签的时候。

撰写回答