A Google Reader api. Programmed in ruby. This is an unofficial api. Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
If you would like to implement your own methods, you can quite easily use the api class provided.
api = GoogleReaderApi::Api.new {:email => 'example@gmail.com', :password => 'the pass'}
# OR
api = GoogleReaderApi::Api.new {:auth => 'token'}
and then you can perform requests using the get_link
and post_link
methods.
# this will give the user info.
api.get_link "api/0/user-info"
# this will add a feed
api.post_link 'api/0/subscription/edit', :s => "feed/#{url}" , :ac => :subscribe
The following methods all use the Api
class, so there is no magic
involved.
# password should be asked by the app using the api
# you probably don't want to type that in cleartext here
user = GoogleReaderApi::User.new {:email => 'example@gmail.com', :password => 'the pass'}
# OR
user = GoogleReaderApi::User.new {:auth => 'token'}
you can access your feeds from there
user.feeds
which will return an array of GoogleReader::Feed objects. then you can get the unread items, the read items, ...
hn = user.feeds.find {|feed| feed.title =~ /hacker news/i }
# return 3 unread items (ordered by date)
hn.unread_items(3)
# return all the read items
hn.read_items
# all the starred items
hn.starred_items
you get the idea. you can like items, star items, and mark them as read or unread.
hn.all_unread_items.each {|item| item.toggle_read}
subscribing to new feeds is also easy
user.subscriptions.add "any feed url here"
unsubscribing is best done via remove_if
method
user.subscriptions.remove_if {|feed| feed.title =~ /hacker news/i}
- provide nicer convenience methods. (user.subscriptions.feeds is not a good way to access your feeds).
- labels should be part of the api.