Note : This document is totally unofficial. You should not rely on anything on this document is you need an exact information. Google Reader API has not officially been released. This document has been made mainly by reverse engeneering the protocol.
Requierements
Google Reader API require :
- http client
- GET and POST support
- Cookie support
- https client
https is only required for identification with Google to get the string called SID. You can rely on an external tool to connect with https and give you SID. If you do, https won't be required.
Cookie support is only required to pass to all pages the current SID, proof of identification. If are able to change add lines in headers, cookie support is not required anymore.
Google Reader API may require :
- http client
- GET and POST support
- external tool to get SID (using https)
- putting SID into header
Glossary
- SID : Session ID. SID is generated each time you login to Google (any service). The SID is valid until you logout.
- user ID : a 20 digits string used by google reader to identify a user. You don't really need to know it. You can always do things a way that user ID is not needed. Usually, when you need that information, just replace it by - and the user ID for current logged user will be used. The user ID never change for a user.
- token : A token is a special 57 chars string that is used like a session identification, but that expire rather quickly. You usaully need a token for direct api calls that change informations. The token is valid for few minutes/hours. If API call fail (doesn't return OK), you just have to get antoher token.
- client ID : A string that identify the client used. I suppose it's for logging/stat purpose, or perhaps to make some adjustement for some clients, but I doubt so. old GoogleReader interface use 'lens', new one use 'scroll'. The writer of this document use 'contact:name-at-host' for interactive test, and use string like 'pyrfeed/0.5.0' for the software pyrfeed in version 0.5.0 (like classical identification strings for unix softwares).
- item/entry : Sometimes called item, sometimes called entry, the item is the base element of a feed. An item usally contain a text, a title and a link, but can contain other properties. An RSS/Atom aggregator aggregates items. (Note: item is the RSS term, while entry is the Atom term).
Identification
Note : According to Mihai Parparita in Google Reader Support Group ( http://groups.google.com/group/Google-Labs-Reader/browse_frm/thread/73a0aed708bcd005 ), "Authentication is one of the reason why the API hasn't been released yet". You should expect big changes before Google Reader release official API.
To login, you need to post with https on https://www.google.com/accounts/ClientLogin with the following POST parameters :
| POST parameter name | POST parameter value |
| service | 'reader' (!) |
| Email | your login |
| Passwd | your password |
| source | your client string identification (!) |
| continue | 'http://www.google.com/' (!) |
Of course, your login and your password are login and password you usually use to identify interactively to Google.
(!) : Those parameters are said to be optional ( http://code.google.com/p/pyrfeed/issues/detail?id=10 ). I didn't really tested. It's just how "browsers" identifies themselfs. Note that I consider source and service as a being informative parameters for google, so I feel like I need to provide them, event if they are not required. Note that I have no idea about what Google or the Google Reader team really think about that. Perhaps they prefer "nothing but a crafted information", or perhaps they don't care. Who knows...
There is no official rule your client string identification, see client ID in glossary for more informations.
The POST action will return you a text file, containing lines of the form :
key=value
You need to extract the value for the key named SID
You then have to add yourself a cookie (well, it look like Google doesn't add it itself) with the following properties :
| name | SID |
| domain | .google.com |
| path | / |
| expires | 1600000000 |
If you don't have a http client API that support cookies, you can just add header lines that simulate this cookie in all other requests. This should be the only thing for which cookies are really needed.
The three layers for feed aggregators
When you're writting a feed aggregator, you need to write three different layers :
- Layer 1 : The layer that parse feeds. It's not the easiest job. "But, it's just xml, it should be easy". It's not. It's just xml. It's just 10 differents and incompatible xml formats (9 RSS formats according to Mark Pilgrim and 1 Atom format). You also perhaps need to understand all non standard feeds that mix some features from differents standards.
- Layer 2 : The database layer. Once you've parsed your feed, you need to store it in a database, and and interesting things like "items read", etc.
- Layer 3 : The user interface.
Google Reader offer in fact acces to layer 1 only, or layer 1+2 or layer 1+2+3.
You can have acces to layer 1 only. Feeds are parsed by Google Reader, and Google Reader give you access to a new Atom feed that contains same data as the original feed, but always with the same output format : Atom.
You can have acces to layer 1+2. This documents purpose is about how to acces to layer 1+2 from Google Reader in order to create your own layer 3.
Of course, you have access to layer 1+2+3 because it's Google Reader's main product.
Url scheme
Except for identification process, all Google Reader url ressources start with http://www.google.com/reader/. We'll explain here direct subspaces of thoses urls.
| URL prefix | Will be refered as, in this document | Description |
| http://www.google.com/reader/atom/ | /atom/ | All urls starting by this prefix return atom feeds. It's the (only?) way to acces to feed contents. This is the way to access layer 1 and layer 1+2. |
| http://www.google.com/reader/api/0/ | /api/0/ | This is the main API entry point. It's used for items/feeds modifications, like adding a Star, deleting a tag, etc. For those modification services, it return either "OK" or "". It's also used to consult some setting lists like list of feeds, list of tags, list of unread counts by feeds/tags, etc. For those read services, it returns an "object" that can be either json or xml that look like json. This is a layer 2 only zone. |
| http://www.google.com/reader/view/ | /view/ | All AJAX interface is done by /view/ urls. AJAX code use /atom/ and /api/0/ as sublayers to do the job. This is the way to access layer 3. |
| http://www.google.com/reader/shared/ | /shared/ | All shared pages use this prefix. You obviously don't need authentification to use those pages. |
| http://www.google.com/reader/settings/ | /settings/ | The AJAX application to configure all settings. Mainly manipulate informations from /api/0/. This part of layer 3. |
Atom set of items
this section is about urls starting by http://www.google.com/reader/atom/
The Google Reader database contains a huge number of items. Some of them are in your reading list (understand, they are accessible in Google Reader for your account in "All items" section, and in your feeds/tags).
The only way to get information related to an item is to "query an atom set of items" that contain this item.
All items are or were included in feeds. One way to query items is to query the original feed.
Item are also associated to categories. tags/labels are categories, but also the "read" state is also a category.
Antoher way to query items is to query all items that are associated to a category.
| Set of items suffix | Description |
| feed/ | url of a feed | The url to query a specific feed. It's Google Reader way to access to layer 1 only. Note : This service is not related to an account and can be access without registration. |
| user/ | user ID/ | label/ | label name | This is the suffix to access to all items with a specific label |
| user/ | user ID/ | state/com.google/ | state | This is the suffix to access to all items with a specific state like read, starred, etc. |
You can use - as your user ID, it will use the user ID for your currently identified account.
| State name | State meaning |
| read | A read item will have the state read |
| kept-unread | Once you've clicked on "keep unread", an item will have the state kept-unread |
| fresh | When a new item of one of your feeds arrive, it's labeled as fresh. When (need to find what remove fresh label), the fresh label disappear. |
| starred | When your mark an item with a star, you set it's starred state |
| broadcast | When your mark an item as being public, you set it's broadcast state |
| reading-list | All you items are flagged with the reading-list state. To see all your items, just ask for items in the state reading-list |
| tracking-body-link-used | Set if you ever clicked on a link in the description of the item. |
| tracking-emailed | Set if you ever emailed the item to someone. |
| tracking-item-link-used | Set if you ever clicked on a link in the description of the item. |
| tracking-kept-unread | Set if you ever mark your read item as unread. |
If you need to query a set of items in an atom format, just query http://www.google.com/reader/atom/ followed by the set of items suffix.
For exemple, if you want to acces to Google Reader's rewritting of the feed http://xkcd.com/rss.xml , you can query http://www.google.com/reader/atom/feed/http://xkcd.com/rss.xml . This can be done whether you are identified or not. If you want to query all your last read items, you can query http://www.google.com/reader/atom/user/-/state/com.google/read .
Each atom set contains by default 20 items. You can change that, and other behaviour by adding parameters to the query.
| GET parameter name | python Google Reader API name | parameter value |
| n | count | Number of items returns in a set of items (default 20) |
| client | client | The default client name (see client in glossary) |
| r | order | By default, items starts now, and go back time. You can change that by specifying this key to the value o (default value is d) |
| ot | start_time | The time (unix time, number of seconds from January 1st, 1970 00:00 UTC) from which to start to get items. Only works for order r=o mode. If the time is older than one month ago, one month ago will be used instead. |
| ck | timestamp | current time stamp, probably used as a quick hack to be sure that cache won't be triggered. |
| xt | exclude_target | another set of items suffix, to be excluded from the query. For exemple, you can query all items from a feed that are not flagged as read. This value start with feed/ or user/, not with !http:// or www |
| c | continuation | a string used for continuation process. Each feed return not all items, but only a certain number of items. You'll find in the atom feed (under the name gr:continuation) a string called continuation. Just add that string as argument for this parameter, and you'll retrieve next items. |
Note : continuation has no meaning, it's just a string to help you find next items. You should not rely on its value to do anything else than that (even if this document will explain how that continuation is generated).
Exemple :
All the 17 first items items from xkcd.com main feed that are not read can be found on the url : http://www.google.com/reader/atom/feed/http://xkcd.com/rss.xml?n=17&ck=1169900000&xt=user/-/state/com.google/read
API
this section is about urls starting by http://www.google.com/reader/api/0/
There are two knids of API commands:
- edit commands
- list commands
The number 0 is probably the API version number. Using that number, it will allow Google Reader to change API while stile maintaining an old API for quite some time.
Edit API
To edit anything in the Google Reader database, you need a token (see glossary). To get a token, just go to http://www.google.com/reader/api/0/token . This url will return a string containing 57 chars. It's the token.
The token url takes optional GET arguments:
| GET parameter name | python Google Reader API name | parameter value |
| ck | timestamp | current time stamp, probably used as a quick hack to be sure that cache won't be triggered. |
| client | client | The default client name (see client in glossary) |
All edit commands use POST to retrieve information (note that GET won't work) but they also take a GET argument.
| GET parameter name | python Google Reader API name | parameter value |
| client | client | The default client name (see client in glossary) |
All edit commands will return either an empty string if failled, either the string "OK". If failed, your token has perhaps expires. You can just try to get a new token. If it still doesn't return OK, it's a failure.
Table of POST aguments for the subscription/edit edit call.
| API call function | POST parameter name | python Google Reader API name | parameter value |
| subscription/edit |
| | s | feed | The subscription feed name, in the form feed/... |
| | t | title | The subscription title, used when adding a new subscription or when changing a subscription name |
| | a | add | A label to add (a label on a subscription is called a folder) in the form user/... |
| | r | remove | A label to remove (a label on a subscription is called a folder) in the form user/... |
| | ac | action | The actions to do. Know values are edit (to add/remove label/forlder to a feed), 'subscribe', 'unsubscribe' |
| | token | token | The mandatory up to date token |
| tag/edit |
| | s | feed | The tag/folder name seen as a feed |
| | pub | public | A boolean string true or false. When true, the tag/folder will become public. When false, the tag/folder will stop being public. |
| | token | token | The mandatory up to date token |
| edit-tag |
| | i | entry | The item/entry to edit, in the form tag:google.com,2005:reader/item/... ( it's the xml id of the entry tag of the atom feed) |
| | a | add | A label/state to add (a label on an item/entry is called a tag) in the form user/... |
| | r | remove | A label/state to remove (a label on an item/entry is called a tag) in the form user/... |
| | ac | action | The actions to do. Know value is edit (to add/remove label/forlder to a feed) |
| | token | token | The mandatory up to date token |
| disable-tag |
| | s | feed | The tag/folder name seen as a feed |
| | ac | action | The actions to do. Know value is disable-tags (to remove a tag/folder) |
| | token | token | The mandatory up to date token |
Exemples :
To subscribe a new feed (for exemple http://xkcd.com/rss.xml), you can call:
http://www.google.com/reader/api/0/subscription/edit?client=contact:myname-at-gmail
with POST arguments : s=http://xkcd.com/rss.xml&ac=subscribe&token=here-put-a-valid-token
To add that feed in a folder (for exemple "comics"), you can call:
http://www.google.com/reader/api/0/subscription/edit?client=contact:myname-at-gmail
with POST arguments : s=http://xkcd.com/rss.xml&ac=edit&a=user/-/label/comics&token=here-put-a-valid-token
Open questions that needs to be fixed :
- Are tag/edit and edit-tag just aliases ?
- Why does removing a tag/folder doesn't take an action while every other calls take actions ?
- Why is there several urls, it seems redundant with the action parameter ?
List API
All those calls can be used with GET requests.
| API call function | GET parameter name | python Google Reader API name | parameter value/API call description |
| tag/list | Get the tag list and shared status for each tag. |
| | output | output | The format of the returned output. may be 'json' or 'xml' |
| | ck | timestamp | current time stamp, probably used as a quick hack to be sure that cache won't be triggered. |
| | client | client | The default client name (see client in glossary) |
| subscription/list | Get the subscription list and shared status for each tag. |
| | output | output | The format of the returned output. may be 'json' or 'xml' |
| | ck | timestamp | current time stamp, probably used as a quick hack to be sure that cache won't be triggered. |
| | client | client | The default client name (see client in glossary) |
| preference/list | Get the preference list (configuration of the account for GoogleReader). |
| | output | output | The format of the returned output. may be 'json' or 'xml' |
| | ck | timestamp | current time stamp, probably used as a quick hack to be sure that cache won't be triggered. |
| | client | client | The default client name (see client in glossary) |
| unread-count | Get all the information about where are located (in term of subscriptions and tags/folders) the unread items. |
| | all | all | 'true' if whole subscriptions/tags are required. (TODO: Needs to check other values) |
| | output | output | The format of the returned output. may be 'json' or 'xml' |
| | ck | timestamp | current time stamp, probably used as a quick hack to be sure that cache won't be triggered. |
| | client | client | The default client name (see client in glossary) |
Viewer
this section is about urls starting by http://www.google.com/reader/view/
All url starting by http://www.google.com/reader/view/ are html pages that use AJAX code to show atom feeds found from http://www.google.com/reader/atom/.
You can append to the base url any set of items suffix to view only that set of items. Note however that GET parameters are not valid (in fact are ignored) for those urls.
You can browse directly all your items labeled "important" by going to http://www.google.com/reader/view/user/-/label/important
You can browse directly all items from xkcd main feed by going to http://www.google.com/reader/view/feed/http://xkcd.com/rss.xml even if you didn't subscribed to it (in which case there will be a button "Subscribe" on the top of the screen). Note however that if you're not identified, you'll browse the feed using the old interface (lens) and not the new on (scroll).
Misc
TODO: Text needs to be written TODO: mainly /share/
References
The api to mark the item as 'read' has slightly changed as on July 15, 2007. The name of the post parameter for token is 'T' and not 'token'.
Also to mark the item as 'read', you would need to pass parameter 'ac' with value 'edit-tags' and 's' with value of the feed url containing the item.
for e.g.
The api to mark the item as 'read' has slightly changed as on July 15, 2007. The name of the post parameter for token is 'T' and not 'token'.
Also to mark the item as 'read', you would need to pass parameter 'ac' with value 'edit-tags' and 's' with value of the feed url containing the item.
for e.g.
The api to mark the item as 'read' has slightly changed as on July 15, 2007. The name of the post parameter for token is 'T' and not 'token'.
Also to mark the item as 'read', you would need to pass parameter 'ac' with value 'edit-tags' and 's' with value of the feed url containing the item.
for e.g.
The api to mark the item as 'read' has slightly changed as on July 15, 2007. The name of the post parameter for token is 'T' and not 'token'.
Also to mark the item as 'read', you would need to pass parameter 'ac' with value 'edit-tags' and 's' with value of the feed url containing the item.
for e.g.
Thanks for posting this! Seems like the API has changed a bit since Niall Kennedy's original article.
In playing with the API tonight, it seems like you have to be logged on in order to get any feeds from GReader...even the http://www.google.com/reader/atom/feed/http://xkcd.com/rss.xml link above seems to require that you are logged in. Has anyone else noticed the same thing?
From the doc, I can't find a way to get the list of feeds subscribed... is that possible?
From the doc, I can't find a way to get the list of feeds subscribed... is that possible?
From the doc, I can't find a way to get the list of feeds subscribed... is that possible?
From the doc, I can't find a way to get the list of feeds subscribed... is that possible?
Sorry for duplicates comments. System bug.
I now know how to get the list of feeds subscribed... It was changed to: http://www.google.com/reader/api/0/subscription/list
The list of unread items count was also changed to: http://www.google.com/reader/api/0/unread-count?all=true
Unfortunately I still can't find a way to get the next 20 items after the first fetch... Maybe is through continuation POST var?
Sorry for duplicates comments. System bug.
I now know how to get the list of feeds subscribed... It was changed to: http://www.google.com/reader/api/0/subscription/list
The list of unread items count was also changed to: http://www.google.com/reader/api/0/unread-count?all=true
Unfortunately I still can't find a way to get the next 20 items after the first fetch... Maybe is through continuation POST var?
I seem to be misunderstanding some stuff... I checked, the continuation is used to get the next items (just like said in the doc). Thanks for the wiki.
note that ck (timestamp) is the standard unix timestamp, with the addition of milliseconds, so instead of 1189800875, it would be 1189800875112
for atom items, the get parameter r (sort order) can also have the value "n" which seems to be a synonym for "d". so "o" is oldest first, "n" is newest first, "d" is descending.
Is there a way to filter a feed searching for a word? something like:
http://www.google.com/reader/view/user/-/label/important/#search/find_my_word
Is there a way to filter a feed searching for a word? something like:
http://www.google.com/reader/view/user/-/label/important/#search/find_my_word
If I pass in the contents of <gr:continuation> as a parameter (c=...), it does jump me down the feed, but always to the same point (maybe post number 40).
Also, if i use n as a parameter it doesn't work for values over 9.
Are these bugs, or am I doing something wrong?
token is actually T= not token= remember it is s=feed/FEEDURL not just s=FEEDURL
What about http://www.google.com/reader/public/atom/user/<uid>/label/<label>
This is the pure RSS atom feed of any tags you make public. It only returns the last 20 entries of the feed. Is there a way to make it return all the entries?
How can I get a URI like "https://www.google.com/reader/public/atom/feed/<feed URI>"? Or "http://www.google.com/reader/public/atom/feed/<feed URI>"? Is this structure just like "/reader/atom/feed/<feed URI>" that is used to request any feed from google reader system? If so, is there any fresh time of google reader system about this <feed URI>? Or fetch the content from <feed URI> and send it to the client just when user request it?
There seems to be lots of other API changes too. For example, for adding a subscription, google reader uses http://www.google.com/reader/api/0/subscription/quickadd?client=myclient with postdata as quickadd=<URL>&ac=subscribe&T=<TOKEN>
I think they might have changed more, and this document might need reviewing.
I'm wondering if they're planning to release an official API someday :(. I'm working on a little Java program to manipulate my unread items, but it's quite painfull right now...
To get feeds beyong 20 feeds pass n=<numbertoretrieve> as GET request. Unfortunately I didn't figure out a way to start the feeds from a given number.
For example: http://www.google.com/reader/atom/feed/http://xkcd.com/atom.xml?n=20
I'm working on an unofficial Java API for Google Reader based on this page's information.
Requierements is spelled requirements
Is there any way to get the specific extensions in each feed? I'd like to be able to view the original itunes extensions through Google Reader because they keep history, but it seems like they strip them out; i.e. it's a bare-bones atom feed.
Is there any way to login in google-reader account by java program only?Means from code, not from google-reader homepage.Ia m sending "Email" and "Passwd" as post parameter to https://www.google.com/accounts/ClientLogin.Then I am getting SID and LSID.Then I am dumoing cookie.But,its not taking setDomain(".google.com") method. What to do? I want to be logged in via code.IS therer any mistake I am doing?Plz help!!!
@swetadri: I'm currently working on it, if you want more info and/or help me, you can contact me at lechtitseb at gmail . com
The "xt" parameter seems to work only for excluding read items. It seems to completely ignore other states, labels, or feed stream IDs beginning "feed/".
Does anyone have a workaround for this?
I have made my own java based google reader api. Theres no documentation, and it is incomplete, but it may be useful for someone. http://www.caip.rutgers.edu/~scarvel/grapijava/
thanks to scarvel8...ur api is useful to me...
scarvel8, did you do the same thing for subscribtion via my yahoo or bloglines?if yes, please let me know
No I haven't, although if I get some free time I will look into it. I am also working on other options not listed in this document, such as being able to load search results. I should have a more complete API up in the next week or two.
ok..if you do for yahoo rssfeeds, plz tell me...
I am trying to access this url with an XMLHttpRequest: http://www.google.com/reader/atom/user/-/state/com.google/broadcast
However, the responseText is a Google error page which says the following: "Further action needs to be taken by your user agent in order to fulfill the request. "
The script goes through a PHP proxy so it can go cross domain. Does anyone know what information Google Reader requires that would fix this error?
Great article! I want to export my google reading list, and a step is to input it into a feedburner feed for further processing. I could not get Google to export the feed, with the correct userID: http://www.google.com/reader/atom/user/123456789123456789123456789/state/com.google/reading-list Is there authentication requirements?
Ok.. answered my own question. I tried a GET with https://www.google.com/accounts/ClientLogin?service=reader&Email=myusername&Passwd=mypassword and got the authentication requirements parameters
Hi thanks for the post.Nice blog.Now this blog is in my favourite bookmark pages. http://www.squidoo.com/papershredderarticles
I out together a very small program that shows a basic way of grabbing GET data from Google Reader with Java. I commented it up so most questions should be answered. Note this is VERY basic, and just intended for people looking for information on how to get started.
http://www.foreverzero.org/Process.java
Has anyone been able to successfully implement the continuation parameter for getting more feed items from a feed? I cant seem to get it to work. The url I create I can put in a browser address bar and it works fine but when I hit it from a server (CURL) it always shows the first n items.
Also, I cant seem to get any of the xt (exclude) links to work. Has anyone pulled this off?
(http://www.google.com/reader/atom/?n=4&xt=user/-/state/com.google/read)
i can read N items from a feed.. i am currently limited by heap size only, yay
i can also query for number of unread items but have no implemented (in java) the ability to mark items as read.. any advice?
I can't make it retrieve more than 999 items from a given feed. Any ideas how I might get more than that?
(I have a few years' worth of friends' facebook status updates cached in Reader, and would love to be able to export them all! http://infoclarity.blogspot.com/2008/06/hidden-in-words.html)
Thanks for the great tips.
Ok, you can probably tell I'm a complete noob at this from my question but here it goes. I'm just trying to make a very simple bash shell script using curl to get my unread count. I can view the data I want just fine when I open this link in safari (http://www.google.com/reader/api/0/unread-count?all=true) and I can view the source and see exactly what I'd like to extract. However, when I use curl in my shell script it doesn't work. I'm assuming I have to login as described at the beginning of the article to access this data using curl. My stupid question is this: is it safe/secure to include my user name and password in this url ( https://www.google.com/accounts/ClientLogin?service=reader&Email=myusername&Passwd=mypassword) in a shell script? Any suggestions would be a big help. Thanks!
For doing any operation which requires authentication, you would need to provide two tokens:
SID Authentication token or T token (do not mix up this token with the Auth token you get by authenticating against Google by ClientLogin?)
SID (session ID) is a session token. There are also two ways of fetching this token:
If you have a browser (i.e Firefox) opened and already logged in any Google site, a valid SID token would be stored inside your browser. Firefox stores session tokens inside session_store.js file. In conclusion, search for the SID inside session_store.js if there is any google session opened inside your Firefox.
Authentication against Google reader service using ClientLogin? mechanism. Google reader service codename is 'reader'. ClienLogin? mechanism is fully documented by Google (just google it). ClientLogin? mechanism returns three tokens, one of them is SID (session token).
Once you got a valid SID token, then you need to retrieve
Once you get a valid SID token, do a GET request to the following URL to get a valid T token.
http://www.google.com/reader/api/0/token
This request should be composed by adding SID as a Cookie.
Once you get both tokens, SID and T, you can successfully perform any Google Reader operations which require authentication (pass these two values as cookies)
So answering the question above, how to compose a valid curl command to fetch a list of unread elements:
First, get a valid SID token:
curl https://www.google.com/accounts/ClientLogin -d Email=just_your_username_here_without_at_gmail_dot_com -d Passwd=your_password_here -d source=Google-cURL-Example -d service=reader
Response: Auth=XXX SID=DQAAAH0AAAC0YHom0L5LDq10xGnbQK_O7OLiX3Qrou4XeA6P469shoM1goEFQT_zVn8YxDV38Y5v3mGJlhSzJuz5xLPqpKEM0Wedks-ak7LLpNjO7dZw779ljOQrC-2UCYFjiktJcfXmof7WeZs7O0SCNCQgPSKaENJ6FBTeDBeQLahUUrajrg LSID=XXX
Once you get a valid SID, request a T token:
curl -s -X GET http://www.google.com/reader/api/0/token --header "Cookie: SID=DQAAAH0AAAC0YHom0L5LDq10xGnbQK_O7OLiX3Qrou4XeA6P469shoM1goEFQT_zVn8YxDV38Y5v3mGJlhSzJuz5xLPqpKEM0Wedks-ak7LLpNjO7dZw779ljOQrC-2UCYFjiktJcfXmof7WeZs7O0SCNCQgPSKaENJ6FBTeDBeQLahUUrajrg"
Response:
kArWxxwBAAA.vegUbtUjv2Vvf_HKWlwjIA.QfhP1LoSb5ghYPz_AbOG_Q
Once you get a valid T token, perform any operation you want against Google Reader, for instance, retrieve your list of feeds
curl -s -X GET http://www.google.com/reader/api/0/unread-count?all=true --header "Cookie: SID=DQAAAH0AAAC0YHom0L5LDq10xGnbQK_O7OLiX3Qrou4XeA6P469shoM1goEFQT_zVn8YxDV38Y5v3mGJlhSzJuz5xLPqpKEM0Wedks-ak7LLpNjO7dZw779ljOQrC-2UCYFjiktJcfXmof7WeZs7O0SCNCQgPSKaENJ6FBTeDBeQLahUUrajrg; T=kArWxxwBAAA.vegUbtUjv2Vvf_HKWlwjIA.QfhP1LoSb5ghYPz_AbOG_Q" | tidy -xml -indent -quiet
Following the curl breadcrumbs of pinowsky (thanks!) I worked up the following Python code to use Google Reader to convert feeds to Atom:
http://wiki.xml3k.org/Amara/Recipes/Google_Web_feed_atomizer
From now it seems like I need to be logged in to access atom/feed/somefeedurl?
I can't use command-line URL-fetchers (like 'wget' or 'GET') successfully when trying to access the following URL: http://www.google.com/reader/atom/feed/http://xkcd.com/rss.xml
They don't return XML data, but rather an HTML page telling me to log in. Is Google restricting access to particular user-agents (browsers)?
Google Reader has feed translation, introduced 2008-11-11.
That's accessible by the parameter/key pair of "trans=true"
ex. http://www.google.com/reader/atom/feed/SOME_FEED_URL?trans=true
the above translates to the language of your setting with Google Reader.
I don't know if you can make it translate to languages of your choice just by varying a parameter.
Is "edit-tag" still working?
I got a "400 client error" when I try to add a label to a specific post of my favorite list. I got a valid SID and Token, but for exemple this URL is not working: http://www.google.com/reader/api/0/edit-tag?ac=edit&i=tag:google.com,2005:reader/item/041fa449c5de72c9&a=user/-/label/test&token=97xa1B0BAAA.RDpLb8-l3NMfqpaw0vYq-g.JcgYUQXFh9E6MmkLNIpwEw
Am I missing something?
Hi,
I am wondering how to sync with GoogleReader?? for offline reading? I want the latest 10 entries that I haven't seen before, e.g. r=d (date descending), n=100, ot=<timestamp of last sync>. But you say above that specifying ot only works with r=o. ;-(
Cheers, Mariano
Hi Mariano -- What you're going to want to do is use the "xt" (exclude target) parameter to exclude read items in your query. Look for "xt" above.
Hi TrashingStick?, I appreciate very much that you took the time to post an answer. I thought nobody would ;-(
But this would not help me really. It is not the same to have donwloaded an item and have read it. So I download a couple of items to a mobile device, read some of them, but then don't want to download the unread items all over again every time I sync. It is also not an option to mark them as read anyway and keep a separate read state on the client. This would make the items marked read for the online reader also.
Any more ideas?
I opened a question on stack overflow: http://stackoverflow.com/questions/384771/how-to-skip-known-entries-when-syncing-with-google-reader
the start_time parameter no longer (or never) works.
no matter what start_time i set, whether r=o or r=n, the oldest feed item returned is within this month.
oh well. if anyone tries to grap all the items. the way is to set n very very big so that it covers all the items.
Will somebody pl tell me - 1. how to mark an item as read (using these api) 2. how to mark many items as read (using theser api)
I tried whatever has been said above.......however not getting it right. Pl explain with an example.
Thanks a ton in advance -shabda
Does anyone know how to solve this...?
I'm trying to roll my own aggregator by running feeds through the API to normalize the contents. Works great for most feeds ("http://www.google.com/reader/atom/feed/#{feed.url}"). However, some feeds use url parameters to deliver their contents... example: "http://img.perezhilton.com/?feed=rss2". The API sees this and thinks the feed address is just "http://img.perezhilton.com/", and that the "?feed=rss2" is a parameter for IT, rather than the feed's server. Escaping the ? does not work... anyone have any clues?
Thanks to all for the awesome work figuring this out.
jackphelps, try urlencoding the whole url:
http://www.google.com/reader/atom/feed/http%3A%2F%2Fimg.perezhilton.com%2F%3Ffeed%3Drss2
this seems to work :). Good luck with your project
I'm getting 401 (Unauthorized) HTTP error, when trying to call "edit" API methods. I've tried to attach "T" token both in post request and as cookie to no avail. Does anyone else get the same error?
I'm have the same problem (401 (Unauthorized))
Google don't allow to remove "user/-/state/com.google/read", and I failed to add "user/-/state/com.google/kept-read". Any tips on how to mark article "unread" now?
Thank you very much for this analysis, it was very helpful.
Here is my small tool written using Reader API (and some python code): managing subscriptions as a text file
katapulp - did you have any luck? I'm having the same issue. I've presented the i, s, & a arguments in every way I can imagine (in the url, as data in the post, URL encoded, not URL encoded) and the same with SID and token, and I always get a 400 or 401 error. Any one here have any luck editing tags? I can read data no problem, I just can't modify.
Hi, For all shared items, how can I get the list of tags for each shared item? I have been trying with the above api and so far unsuccessful. Any suggestions are appreciated. Thanks.
To catapulp and wayne.culbreth:
I have a working 'edit-tag' feature of marking entries as read in the following way:
Post to url: http://www.google.com/reader/api/0/edit-tag?client=- Post body: "i="+entryId+"&a=user/-/state/com.google/read&ac=edit&T="+token
Other combinations of T->token, ac=edit->ac=edit-tags, adding s=feedURL and so on come to 400 error from Google.
Hello guys ,
I am planning to write an application that simulates a Feed Reader and manager and I decided to write it in SIlverlight (it sounded interesting and I hope I will learn a lot).
My first problem was somehow to "generalize" the feeds brought into the application. After some research I found out Google Reader offers the posibility to access their first layer ( parsing layer) and in this way I could get the feed in atom format for any feed.
(using http://www.google.com/reader/atom/feed/[URL] command)
Ok ,things were clear until here .I already knew that for an SIlverligt appication to exist the posibility to extract some data from another location than it's domani ,that data site should have a crossdomain.xml file in the root of the site.
My thought was first that Google has something like this ,I also was enthusiastic when found reply to crossdomain.xml. But disappointment come soon because on a closer look the xml file looks like :
<?xml version="1.0"?> <!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/ dtds/cross-domain-policy.dtd"> <cross-domain-policy>
</cross-domain-policy>So my first idea was to use a proxy to access this link ,I am new in this technology and tried some solutions:
SIlverlight can extract for example any data through a proxy ,for example this works: http://al.cloudapp.net/proxy.ashx?http://rss.cnn.com/rss/edition.rss ,it extracts the direct feed from cnn site even if they don't have a crossdomain.xml file.
My next step was to generalize the feed through Google Reader :
http://al.cloudapp.net/proxy.ashx?http://www.google.com/reader/atom/feed/http://rss.cnn.com/rss/edition.rss ,but this solution failed ,I also tried with different proxies and no success.
My questions would be:
1.Why Google has this crossdomain.xml file and not a more permissive one? Could it be possible to modify this crossdomain.xml so that Silverlight application can access this API?
2.If 1 is not possible does anyone have a better solution ,I feel I am very close and maybe it may work through a proxy and I am doing something wrong?
3.Anyone else have any other ideas?
Thanks a lot, Ionut
Hello. Just found this and have only begun digging in, but my first simple test is failing and it seems to be a "mad-made" issue. Google Reader shows that I have 84 unread items, yet the following code only returns 20 entries:
xmlfeed = gr.get_all() print xmlfeed.get_title() for entry in xmlfeed.get_entries(): print entryI see a 'count' parameter in ATOM_ARGS which may be used to limit the number of items (?) and "20" is a suspiciously convenient and round number, but I dont see any reference to 20 in the code... Is the response limited to 20 items?
Has anyone looked into emulating the ability of the bookmarklet they release (http://googlereader.blogspot.com/2008/05/share-anything-anytime-anywhere.html). It allows you to share an item even if it isn't in one of your feeds. Would be nice to be able to duplicate this in the code too.
Mine works for a little while, but then I get a 302 redirection and the message "Further action needs to be taken by your user agent in order to fulfill the request." After some period of time (I'm not sure how long yet) it will start working again.
If anyone aware of a limit to how often you can access the API during a period of time. I always get to a similar point (>100 I think) before getting the redirection.
I've already queried atom feeds from it several thousand times in testing my app. Seems to be no problem there.
Does anybody know how to eliminate duplicates of entries which google returns sometime with the http://www.google.com/reader/atom/ API? This often happens when the RSS creators update entry, but the URL or id of the entry is changed. The same feed explored with Google Reader web interface doesn't contain duplicates, which appear with Reader API. While Google Reader is based on the GoogleReader? API it should be possible to avoid duplicates with API too.
How can I get a list of unread news (with the title)?
Trying to make edit tag work. I've got the data to be sent by using Firebug in Firefox and using online Google Reader. The result is return of "Invalid stream name." Anybody knows what that means?
Hey i am getting a 400 error when i try to add a subscription list to google reader. Here is what I am doing
url = "http://www.google.com/reader/api/0/subscription/edit?client=-"
I set my http request url to this
and pass the following post parameters
postRequestPayload=feed/http://xkcd.com/rss.xml&ac=subscribe&T="+token.
I have also tried token instead of T and also tried client=scroll in my url but I still get the 400 error. Please help.
The official Google Reader desktop gadget uses the API, so accurate API information can be gathered from it: http://code.google.com/p/google-reader-gadget/
I was using the following url http://www.google.com/reader/atom/feed/http://.. to be able to download all the feeds that i would eventually miss when my RSS Client is off. Why is not working any more?? I get this error in safari: “The feed could not be loaded because the content is not in a known feed format.” (PubSub?:2)
Fixed. The problem was something regarding cookies. I just needed to logout, delete the cookies in safari and login again. I recommend to use those url if the feed you're watching has more than 20 updates per day as the Client/feed might not pick more than that. -GianPaJ
I am using this URL to get unread headlines: https://www.google.com/reader/atom/user/-/state/com.google/reading-list?xt=user/-/state/com.google/read
Is there a query string parameter to exclude elements like <summary>? That would mean I would download a lot less data.
I discovered that the "broadcast-friends" state is for items that your friends have shared (i.e. are in the People You Follow section).
My HTTP requests to Google Reader API return HTTP 403 response. Everything worked fine until i've started experiment to check for new entries in cycle for about 4000 feeds. It looks like some kind of ban but i can't find any published restrictions on service usage. Does any body know about restrictions or about the way to pass the problem without changing the IP?
I have found the JSON version of /reader/atom/user/-/state/com.google/reading-list if anyone is interested:
http://www.google.com/reader/api/0/stream/contents/?xt=user/-/state/com.google/read
Everything was working fine, and then I started getting the message "Your client does not have permission to get URL /reader/api/0/token from this server," when requesting a token despite not having changed any code. Has anyone else experienced this?
@dmatarazzo I'm having the same problem. =\
@ruimams I figured out that the problem was with how I was setting up the cookie that contained the SID. Could that be the source of your problem? As long as you're using POST, sending a cookie (I sent mine through the header) that reads SID=SID here? and using the /reader/api/0/token URL, it should work...
Since there isn't an "unread" state, to get a list of all unread items just query your reading list with a very large number and exclude read items like so: http://www.google.com/reader/atom/user/-/state/com.google/reading-list?n=9999&xt=user/-/state/com.google/read
How do you "mark as read " ?
I've tried sending : URL : http://www.google.com/reader/api/0/edit-tag Post values : i = tag:google.com,2005:reader/item/03052da1635b7fdb a = /user/-/state/com.google/read T = token value I include the sessions cookies as well.
Thanks.
Answering my post above. I had a slash in front of 'user' in the 'a' tag. 'ac' tag is set to 'edit-tags'. URL encode the token, 'i', and 's'. It works now.
This is great!!! Can we use this API for a commercial product? Can someone at google respond to me cyberprashant at gmail dot com. Thanks!
Hello,
I'm working with .NET, and I looking .NET component tall with Google Reader API
Now, I use component at: http://mattberseth.com/blog/2009/02/net_googlereader_api.html
In my code, I get rss from google news but have error - bad request
http://www.google.com/reader/atom/feed/http://news.google.com/news?cf=all&ned=us&hl=en&q=obama&cf=all&output=rss
How to fix this error?
Pls help me!
Nice article. Just tried it to get all my feeds on Google reader.
Thanks.
@ng2tuan:
Try urlencoding the feed URL. The ? is your problem.
I've had my server checking feeds using the Google Reader API for a long time now and all of a sudden I'm getting 302 redirections because it's coming from an automated script. Is anyone else seeing this?
I've been fetching feeds directly from Google so I can have the Google ID's for each item to promote syncing. If anyone knows of another method for this I would love to hear it.
I have installed everything just as indicated, but obtain the following error when trying to run pyrfeed.py: AttributeError??: 'module' object has no attribute 'EVT_BeforeNavigate2?? Any ideas? Thanks,
Gonzalo
spelling fix (diff):
-You should not rely on anything on this document is you need an exact information. +You should not rely on anything on this document if you need an exact information.
How to get like count for an item?
Does Google change the api? My RSS reader for Android is work normally before. But It can't link and always return fail these days. Who can tell me why?
There's a feed discovery api in json or atom.
Quoting http://groups.google.com/group/google-reader-howdoi/browse_thread/thread/2f907767c1e63d20/593f09db6dad99b2#593f09db6dad99b2
You can get basic feed finding information as either Atom or JSON: http://www.google.com/reader/api/0/feed-finder?q=http://www.boston.com/bigpicture/&output=atom http://www.google.com/reader/api/0/feed-finder?q=http://www.boston.com/bigpicture/&output=json Once you have the feed URL you can get stats for it as XML or JSON (note that this requires you to be logged in): http://www.google.com/reader/api/0/stream/details?s=feed/http://www.boston.com/bigpicture/index.xml&output=xml http://www.google.com/reader/api/0/stream/details?s=feed/http://www.boston.com/bigpicture/index.xml&output=json Mihai Parparita Google Reader Engineer
(formatting sucks, sorry. see the original.)
Please help!
post url: http://www.google.com/reader/api/0/subscription/edit
post parameter: Cookie:SID=mysid client=- s=feed/http://rss.sina.com.cn/news/marquee/ddt.xml ac=subscribe T=mytoken
response:http 401 error
Missing any parameter?url changed?
When can we have a offical document for google reader api?
If anyone is interested there is also output=proto for outputting in Google's own Protocol Buffers binary format. For example, http://www.google.com/reader/api/0/unread-count?output=proto
This is what I have been looking for long time.
Anyone know how to get all articles changed since a given date/time? Ie, I want not only new articles since a given date, but also any articles that had a state change such as read, unread, favorite, etc.
Just need the .proto files now to be able to decode the protocol buffer API responses. I have tried searching for them with no success yet.
Just created a tiny ruby test script for accessing the API to add / remove subscriptions and labels in my reader. (Will use this functions later on in an other script). I also used the Authorization-Header-Authentication instead of Cookie-Authentication.
If someone is interested in this script you can see it at http://gist.github.com/341399
Is authentication still a problem for reading an user's data in Google Reader?
Can't AuthSub? or OAuth be used around this to get access to data without providing username and password?
'n' is limited to 1000. If you need to get more items than 1000 you have to use 'continuation'. So annoying.
Sample PHP code for adding/removing a feed (see above for getting session ID and token):
// adding a feed $ch = curl_init(); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_URL, "http://www.google.com/reader/api/0/subscription/quickadd?client=scroll"); curl_setopt ($ch, CURLOPT_COOKIE, 'SID='.$this->session_id); curl_setopt ($ch, CURLOPT_POST, 1); //curl_setopt ($ch, CURLOPT_POSTFIELDS, array('quickadd'=>urlencode($feed_url),'T'=>$token)); // will not work curl_setopt ($ch, CURLOPT_POSTFIELDS, 'quickadd='.urlencode($feed_url).'&T='.$token); curl_setopt ($ch, CURLOPT_USERAGENT, $this->user_agent); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $content = curl_exec($ch); curl_close($ch);http://www.blogger.com/home
google modified the access param "token" to "T" for "www.google.com/reader/api/0"
"/api/0/token" will return a string containing 22 chars
How can I filter (or search) the feed results based on a keyword search, similar to how you search in google reader?
I am able to get the following results from a shared feed that I’ve made public. I actually get the same results with the following 2 URL’s (notice the first has “public” in it.
http://www.google.com/reader/public/atom/user/02147574221729223002/bundle/Fantasy%20Football%20NFL%20Articles?n=10
http://www.google.com/reader/atom/user/02147574221729223002/bundle/Fantasy%20Football%20NFL%20Articles?n=10
Lets say I wish to filter the results above based on a keyword, "Roethlisberger".
When I search a folder using the search form in reader, the url shows as:
http://www.google.com/reader/view/#search/Roethlisberger//user%2F02147574221729223002%2Flabel%2FSports
If I change the reader tag to “atom”, the results are incorrect.
Thoughts? -Gurpreet
Hi, I am trying to use the reader api to get feeds that I have been tracking since early 2009. However, I noticed that my feeds seem to only read 1000 items before a limit is reached. Is there some setting that allows one to access feeds with a much higher maximum number count?
Hi, Any idea how to search for a particular entry guid, or original-id?
I know the original-id and I want to make updates to the google version, how do I map between? Thanks, T
Is cookie SID a secure thing? I get it via /accounts/ClientLogin?, then i unvalidate it via /accounts/Logout, but stil can feach private data with curl -H "Cookie: SID=$SID" ... What about, if anyone found one of my SID strings?
Hey everyone,
I'm getting 400 errors when trying to star an item, and I can't figure out why. Here is the URL:
http://www.google.com/reader/api/0/edit-tag?i=tag%3Agoogle.com%2C2005%3Areader%2Fitem%2F97e73baae1c833d6&s=feed%2Fhttp%3A%2F%2Fwww.slickdeals.net%2Frss.php&a=user%2F-%2Fstate%2Fcom.google%2Fstarred&T=_2g76ZvXODPljRi-gCP42A
I've also tried passing ac=edit, ac=edit-tags, and URL Encoding and not URL Encoding variables. I am passing the SID as a cookie, and all my queries work fine, such as getting unread lists and items. But as soon as I try to use the edit-tag api it fails.
Ideas?
Any new opinions on how to subscrie to a feed ? I'm using C#:
I create a http web request with POST here: http://www.google.com/reader/api/0/subscription/quickadd with GET params : client = scroll and ck = ... and POST params : quickadd = feedURL, T = token
I attached the cookie and pust an user agent to the request, but I still get 401. Is there someone who has succeeded in making this request ? I've double checked with these params using Firebug, but still no succes
hey can anyone tell me about how to get 'ot' value?
Hi!
This wiki page greatly helped me in writing my own application for reading rss news. (I might publish it soon).
My application was working fine for couple of months now. However, google reader responses started to return information about authentication requirement. Logging in is still successful and SID cookie is created the same way.
Does anyone know what might have changed?
This seems to be broken as of June 2010 . My app which has worked for months is now getting a unauthorised from googles servers... Hopefully we will get an official API soon...
I have just found http://www.google.com/support/forum/p/reader/thread?tid=5698d3dc3cfa4470&hl=en which points to: http://groups.google.com/group/fougrapi/browse_thread/thread/e331f37f7f126c00
I have not tried to use it yet.
Using:
works :)
header
name : Authorization value : GoogleLogin? auth=obtained from ClientLogin?
Authorization:GoogleLogin? auth=obtained from ClientLogin?
How to use that?
Add the following header to your HTTP request. Name: "Authorization", Value: "GoogleLogin? auth=<ADD AUTH TOKEN HERE>"
Does anyone have a complete header request? My requests were working with SID, but I've tried adding the headers as above with/without my old SID header and my new auth. I'm getting 400 error.
I've had the same problem as of a few days ago and can't resolve it. Tried the GoogleLogin? in the header and still get a 401 when requesting a google reader URL that worked fine for weeks before. Anyone else get this resolved? Did you completely drop the SID? Is a space ok in the header between Authorization and GoogleLogin??
when you get the SID at https://www.google.com/accounts/ClientLogin, there is now a new additional parameter 'Auth'. you need to extract it and use it in the HTTP request header of every request to the google reader in the following way: add a new header variable 'Authorization', where its value is 'GoogleLogin? auth={here add the Auth variable you got from where the SID is}'. all the rest stays the same!
i cant get my app to work with new auth method: is still required the GET call to http://www.google.com/reader/api/0/token or the auth= value received from GoogleLogin? can be used as token my try was 1) save the valued of ath, add header, call api/0/token = error 403 2) save the valued of ath, add header call directly reader/api/0/subscription/list?client=pushNews&output=json = error 401
since few days ago all was working with SID+token
For those using the cookie method, this is working for me:
"Cookie: SID={sid string}\r\nAuthorization:GoogleLogin? auth={auth string}"
Be sure to remove the '?' after 'G00gleLog1n?'
im quite sure to do all correctly, but still got error :(
this's the routine: SID (no more useful) and Auth correctly read with /accounts/ClientLogin?
try to retrieve the token: request = [alloc? init];
i still got error 403
thanks for any tips
my God, 2 days lost for a stupid error: i was not stripping the last linefeed in the response of ClientLogin? now with posted routine all is ok
I can not change read/unread by edit-tag. But I can get token correctly. Can anyone tell me why? Thx a lot !
Authorization problem fix The following amendments to two documents \GoogleReader?\reader.py \GoogleReader?\web\web.py
reader.py
import time import urllib import cookielib # TODO : Get rise of web package. from web import web
# TODO : Use those line when python 2.6 will be out, for now, there is no # reasons to not be compatible with python 2.4 just to please PEP 238 ! # (lines will be mandatory only with python 2.7) # from .feed import GoogleFeed? # from .object import GoogleObject? # from .const import CONST from feed import GoogleFeed? from object import GoogleObject? from const import CONST
def utf8(s): return s.encode('utf-8','ignore') if isinstance(s, unicode) else str(s)
class GoogleReader?(object) :
## self.token = self.Auth token
def test() :
## xmlfeed = gr.get_feed(order=CONST.ORDER_REVERSE,count=3,ot=1166607627) ## print xmlfeed.get_title() ## for entry in xmlfeed.get_entries() : ## print " %s %s %s\n" % (entry['google_id'],entry['published'],entry['title']) ## print xmlfeed.get_continuation()
if name=='main' :
web.py
#!/usr/bin/perl
# --------------------------------------------------------------
import socket import urllib import urllib2 import cookielib
from resolvUrl.resolvUrl import resolvUrl # from SSLproxy import ConnectHTTPHandler from SSLproxy import ConnectHTTPSHandler
# --------------------------------------------------------------
DEFAULT_AGENT = "Mozilla/4.0 (compatible; MSIE 5.5; Windows 98; Win 9x 4.90)"
# --------------------------------------------------------------
class AppURLopener(urllib.FancyURLopener):
# --------------------------------------------------------------
class webUrllib :
# --------------------------------------------------------------
class webUrllib2 :
# --------------------------------------------------------------
web = webUrllib2
# --------------------------------------------------------------
if name == "main" :
#
I am trying to convert a feed to atom using Google Reader and then saving it locally to my server.I am using a php script with curl.No matter what i have tried the saved xml says that further action needs to be taken by my agent.I have already logged in to Google with curl and have retieved SID, Auth and token (event though i don't need them all for accessing layer 1) and i have used both the header method and the cookie method but still Google does not allow me to save the result to a file.I have googled around but i haven't found anyone attempting this.The closest is this python feed converter http://wiki.xml3k.org/Amara2/Recipes/Google_Web_feed_atomizer Can anyone help?Thank you
Are we need is auth token in header now, we don't need to set cookie anymore. The follow is a example using java with apache httpclient:
DefaultHttpClient httpClient = new DefaultHttpClient(); HttpGet httpget = new HttpGet(url); httpget.setHeader("Authorization", "GoogleLogin auth=" + authToken); HttpResponse response = httpClient.execute(httpget);I have the same issue, I had a working python script and now it not longer works returning a 401 auth error, with either old cookie based auth or the method mentioned above :(
Here's the main code:
url = "https://www.google.com/reader/api/0/unread-count?all=true" request = urllib2.Request(url, None, auth_header) response = urllib2.urlopen(request) unreadxml = response.read()And here is the function that provides the Auth_header dict object:
def getAuthorizationHeader(self): # Authenticate to obtain SID auth_url = 'https://www.google.com/accounts/ClientLogin' auth_req_data = urllib.urlencode({'Email': self.options.username, 'Passwd': self.options.password}) auth_req = urllib2.Request(auth_url, data=auth_req_data) auth_resp = urllib2.urlopen(auth_req) auth_resp_content = auth_resp.read() auth_resp_dict = dict(x.split('=') for x in auth_resp_content.split('\n') if x) SID = auth_resp_dict["SID"] # Create a auth key in the header using the SID header = {} header["Authorization"] = "GoogleLogin auth=" + SID return headerFixed the auth header function, had to use the auth key and not the previously used SID, also had to add the service key into the request:
def getAuthorizationHeader(self): # Authenticate to obtain SID auth_url = 'https://www.google.com/accounts/ClientLogin' auth_req_data = urllib.urlencode({'Email': self.options.username, 'Passwd': self.options.password, 'service': 'reader'}) auth_req = urllib2.Request(auth_url, data=auth_req_data) auth_resp = urllib2.urlopen(auth_req) auth_resp_content = auth_resp.read() auth_resp_dict = dict(x.split('=') for x in auth_resp_content.split('\n') if x) AUTH = auth_resp_dict["Auth"] # Create a header using the AUTH key header = {"Authorization" : "GoogleLogin auth=%s"%AUTH} return headerCant figure out why i couldn't make this PHP code work before, but it does now.Here's a php example on how to download and store locally the converted feeds.
<?php $path = "GoogleFeed.xml"; $url = "http://your_feed_url"; $feed_url = "http://www.google.com/reader/atom/feed/$url?n=100"; //Parameters required to login to Google $params = array('accountType' => 'GOOGLE', 'Email' => 'example@gmail.com', 'Passwd' => 'your_passwd', 'source'=>'PHP-cUrl-GooleLogin', 'service'=>'reader'); //Login to Google $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://www.google.com/accounts/ClientLogin"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); $googleResponse = curl_exec($ch); curl_close ($ch); //Retrieve the SID and Auth parameters for further Google transactions $sid = substr($googleResponse,4,203); $pos = strpos($googleResponse,"Auth="); $pos = $pos+5; $auth = substr($googleResponse,$pos,224); //Connect to Google Reader and retrieve the user's feed in Atom form spanning at least 100 entry elements $headers = array( "Authorization: GoogleLogin auth=" . $auth, "GData-Version: 3.0", ); $agent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.7) Gecko/20100713 Firefox/3.6.7"; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $feed_url); curl_setopt($curl, CURLOPT_USERAGENT, $agent); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_POST, false); //Save Google Reader's response directly to a file $fp = fopen($path, 'w'); curl_setopt($curl, CURLOPT_FILE, $fp); curl_exec($curl); curl_close ($curl); fclose($fp); ?>Is there a way to paginate the feed?
suppose, I setup my feed 20 per page using Atom set method, and now i want to jump to 5th page directly (that means, post 81 to 100).. is there a way to do that?
something like http://www.google.com/reader/atom/user/-/state/com.google/broadcast?n=20&page=5
is there a way to do this?
Hey,
can I get the feed with content that is not html formatted ? Or I can only get html formatted content from google reader, thanks
A few corrections (it seems the API has changed somewhat):
To be continued...
Hello,
I have some problems to mark an item as read I have an error 400 or 401. I'm developping on Android and using JSoup to send the request
Thanks
Has anyone found a way to get sort by Magic working? Do any apps have this feature at all? Can't find it anywhere but on the GR site.
Hello,
Can anyone post a complete URL that works with the current API for marking all items as read? I have tried:
http://www.google.com/reader/api/0/edit-tag?i=tag:google.com,2005:reader/item/03052da1635b7fdb&a=user/-/state/com.google/read&ac=edit-tags&T=[token]
but I get a 401 error.
Many thanks.
I am very much pleased with the contents you have mentioned.I wanted to thank you for this great article. http://www.Craigslistz.org
string args="?i=tag:google.com,2005:reader/item/2ee53214436e17a5&a=user/-/state/com.google/read&ac=edit&T=//4Dk64M97g7q9Afbad301sA" HttpWebResponse? response = httpPost("https://www.google.com/reader/api/0/token/edit-tag/client", args); private HttpWebResponse? httpPost(string requestUrl, string postArgs) { byte buffer = Encoding.GetEncoding?(1252).GetBytes?(postArgs); //byte buffer = Encoding.GetEncoding?(65001).GetBytes?(postArgs); HttpWebRequest? request = (HttpWebRequest?)WebRequest?.Create(requestUrl); request.Method = "POST"; request.CookieContainer? = new CookieContainer?(); request.CookieContainer?.Add(cookie); request.ContentType? = "application/x-www-form-urlencoded"; request.ContentLength? = buffer.Length; request.Headers.Add("Authorization", "GoogleLogin? auth=" + auth); Stream PostData? = request.GetRequestStream?(); PostData?.Write(buffer, 0, buffer.Length); PostData?.Close(); try { return (HttpWebResponse?)request.GetResponse?(); } catch(Exception ee) { MessageBox?.Show(ee.Message); return null; } }it got "404 error"! who can help me!thx
It seemed that one can clear "state/com.google/read" state only if entry have "state/com.google/fresh". Otherwise read state is not cleared though request returns "OK"
for edit-tag reqiest you should send following post fields:
i - for id of item (eg. tag:google.com,2005:reader/item/b1b915a7dfa70337)
a or r - for add or remove tag name (eg. user/-/label/tagname)
s - for feed url of item starting with feed/ (eg. feed/http://habrahabr.ru/rss/)
T - for token
when using ios make sure you add
NSString authHeader = stringWithFormat:@"GoogleLogin %@", authString?;
addValue:authHeader forHTTPHeaderField:@"Authorization"?;
to every GET
Some specific behaviour: items in "starred" folder always have "fresh" label, so always can be marked as "unread"; if this very entry in original folder doesn't have "fresh" label, then unread states may differs in original and "starred" folders. If entry in original folder have "fresh" label, then unread state reflects such state in "starred" folder. weird. if you get entryes filtered by "starred" label, you cant'be sure if entry is in "read" state in original folder. seemes as some bug in GoogleReader? logic.
I'm trying to add a feed to my Google reader account with a call to http://www.google.com/reader/api/0/subscription/edit but I'm getting an error saying "POST requests require a Content-length header." This is using curl in PHP. I can log in and get a token, the next step is where I get the error. Here is my code:
$ch = curl_init();
$data = array('accountType' => 'GOOGLE', 'Email' => 'user@domain.com', 'Passwd' => 'password', 'source'=>'nameyourapp', 'service'=>'reader');
curl_setopt($ch, CURLOPT_URL, "https://www.google.com/accounts/ClientLogin"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$loginResult = curl_exec($ch);
$authRaw = strstr($loginResult, "Auth"); $authToken = substr($authRaw, 5); $header = 'Authorization: GoogleLogin?? auth='.$authToken;
curl_setopt($ch, CURLOPT_URL, "http://www.google.com/reader/api/0/token"); curl_setopt($ch, CURLOPT_POST, false); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$token = curl_exec($ch);
//everything works fine up to here
$data = array('s' => 'http://feeds.feedburner.com/TechCrunch', 'ac' => 'subscribe', 'a' => 'user/-/label/techcrunch', 'token'=> $token); $data = http_build_query($data); $header = 'Content-length: ' . strlen($data);
curl_setopt($ch, CURLOPT_URL, "http://www.google.com/reader/api/0/subscription/edit?client=contact:user@domain.com"); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch); curl_close($ch);
print ($result);
As you can see, I am sending the content-length header. But the error makes it sound like it's not even there. I've searched Google and found other people having this error message with different Google services, but none of them seem to be able to resolve the issue. Some of them make it sound like it's a problem on Google's end. Please help!
Hi Whenever i try to subscribe a url on google reader, getting below error
//nCt3Vgbs0Xgj7Jx_jNpWvQ<html><head><title>400 Client Error</title>
first I try to get token, I am getting token from this url http://www.google.com/reader/api/0/token response //nCt3Vgbs0Xgj7Jx_jNpWvQ saving token string in pStrToken? = nCt3Vgbs0Xgj7Jx_jNpWvQ then i try to send subscribe url to google reader http://www.google.com/reader/api/0/subscription/quickadd?ck=<timestamp>&client=FeedViewer?&quickadd=<feed://timesofindia.feedsportal.com/c/33039/f/533915/index.rss>&ac=subscribe&token=<nCt3Vgbs0Xgj7Jx_jNpWvQ>
and always getting error.
Please see my iphone code #define SUBSCRIBE_URL @"http://www.google.com/reader/api/0/subscription/quickadd?ck=%@&client=FeedViewer&quickadd=%@&ac=subscribe&token=%@" #define SUBSCRIBE_URL_VALUE @"feed%2Fhttp://feeds.feedburner.com/TechCrunch?" pStrToken?= nCt3Vgbs0Xgj7Jx_jNpWvQ ;
NSTimeInterval timeInterval = [date? timeIntervalSince1970];
Please suggest if I am doing any thing wrong.
Following this http://code.google.com/apis/accounts/docs/OAuth2.html I managed to get an OAuth2 access_token, but I can't make use of it... Keep returning Status=Unauthorized - 401
To use the OAuth flow u can try to set the scope? param:
Example:
If anybody figure this out, please share it :D
I have forked a fork of this class here ;) https://github.com/brutuscat/googlereader. It currently works so try it :D
Is there a way to get a feed of your starred news items, BUT only for a certain folder or tag (or even feed).
My idea is to put this rss feed into Boxee so I see only my starred YouTube? Subscription video, and not all of them like at the moment. http://gdata.youtube.com/feeds/base/users/USERNAME/newsubscriptionvideos
http://googlesystem.blogspot.com/2009/05/feed-for-youtube-subscriptions.html
Does kept-unread mean the box was specifically only checked marked and tracking-kept-unread will be a superset of kept-unread?
Here is a class I have developed, in order to use this Google Reader API in JAVA : http://lewebenbien.wordpress.com/2011/06/06/google-reader-api/ Hope that could be useful for someone else :)
hello i want to add smart feed adding to my program, so i need the api url to retreive a feed list maching a keyword (in browser the page is http://www.google.fr/reader/view/?#directory-search/<MY_KEYWORD>//0 ) thanks a lot PS :the page can retreive multiple times the same url in results but i want only one time each (maybe an additional parameter). i want results as a list of subscriptions : - string:title - string:url - int:nbsuscribers - float:nbnewsbyweek - bool:suscribed (no mandatory, since i can compute it myself)
hello i want to add smart feed adding to my program, so i need the api url to retreive a feed list maching a keyword (in browser the page is http://www.google.fr/reader/view/?#directory-search/<MY_KEYWORD>//0 ) thanks a lot PS :the page can retreive multiple times the same url in results but i want only one time each (maybe an additional parameter). i want results as a list of subscriptions : - string:title - string:url - int:nbsuscribers - float:nbnewsbyweek - bool:suscribed (no mandatory, since i can compute it myself)
Hello, i am using unofficial Google Reader Api in my iPhone application. I am facing problem in syncing my app with google reader. if any item become read from unRead state by clicking on in browser then how i can permit this change in my app?. How i can get all items that are clicked as read in the browser, and retrieve in iphone app?? Thanks in Advance..
This document should be update now, to see http://undoc.in/googlereader.html
HI , please one question. I want to get 999 atoms for one particular user. It works like http://www.google.com/reader/atom/user%2F14750707885618507930%2Fstate%2Fcom.google%2Freading-list but here I onle get 20 items. How can I get 999 Items? Thanks
You should use parameter n (count).
Hello everyone. Need help. I try to set a star for feed.
I use these params as post args: key = i, value =tag:google.com,2005:reader/item/88a3ce8e14832f39
key = T, value =eMMPqk1Ls1gA6EIi5ml0nw
key = async, value =true
key = a, value =user/-/state/com.google/starred
key = ac, value =edit-tags
These params I use for header args:
key = client, value =googlereader-ios-client
key = ck, value =1322744198
In reply I get html with an error "There was an error in your request.". The same error occurs when I try to mark a feed as read, favourite and others.
Does Google Alert (via ATOM Feed) include social mentions (in FB, TW, G+) ?
What does "published" and "updated" fields mean? Is it a date ? If it is date then explain what does "1325880983" mean as date ?
@Valeh: They are UNIX timestamps. See http://en.wikipedia.org/wiki/Unix_time. 1325880983 corresponds to Fri, 06 Jan 2012 20:16:23 GMT.