开发者

get Unread Count of Google Reader using Javascript(jQuery)

i'm trying to get the unread count of my google reader using javascript.

tried the following:

var unreadURL   = "http://www.google.com/reader/api/0/unread-count?all=true";

$.ajax({
    url: unreadURL,
    success: function (data) {
        console.log(data);
   开发者_StackOverflow社区 }
});

but im getting a 401. i think i have to authenticate or something, but i have no idea how to do this.

i found this topic, and they are first authenticating using another page, and then setting a cookie (if i read this python right), but i'm not familiar with python and don't know what to do in javascript.

any hints please?


You are correct in stating that you need to authenticate to use the service. However, for security reasons modern day browsers do not allow client-side code to make calls to third party sites. There are ways to get around this, but the typical approach to this problem is to make your requests to the third party site form the server-side then return the results to the client.

So, in your case you can make an Ajax call to server-side code running on your site. This code would then:

  • Use the Google ClientLogin API to authenticate to the Google
  • Get the unread-count
  • Return the results to your client-side code (the result could also be in XML or JSON format)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜