Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 38 lines (29 sloc) 1.147 kb
99cd89d John Nunemaker added delicious example and tweaked the twitter example
authored
1 dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
1d48da0 John Nunemaker Renamed to HTTParty which is way more fun and unique than boring old web...
authored
2 require File.join(dir, 'httparty')
99cd89d John Nunemaker added delicious example and tweaked the twitter example
authored
3 require 'pp'
4 config = YAML::load(File.read(File.join(ENV['HOME'], '.delicious')))
5
6 class Delicious
1d48da0 John Nunemaker Renamed to HTTParty which is way more fun and unique than boring old web...
authored
7 include HTTParty
99cd89d John Nunemaker added delicious example and tweaked the twitter example
authored
8
9 base_uri 'https://api.del.icio.us/v1'
10 format :xml
11
12 def initialize(user, pass)
13 self.class.basic_auth(user, pass)
14 end
15
16 # query params that filter the posts are:
17 # tag (optional). Filter by this tag.
18 # dt (optional). Filter by this date (CCYY-MM-DDThh:mm:ssZ).
19 # url (optional). Filter by this url.
20 # ie: posts(:query => {:tag => 'ruby'})
21 def posts(options={})
22 self.class.get('/posts/get', options)['posts']['post'].map { |b| b.to_struct }
23 end
24
25 # query params that filter the posts are:
26 # tag (optional). Filter by this tag.
27 # count (optional). Number of items to retrieve (Default:15, Maximum:100).
28 def recent(options={})
29 self.class.get('/posts/recent', options)['posts']['post'].map { |b| b.to_struct }
30 end
31 end
32
33 pp Delicious.new(config['username'], config['password']).posts
34
35 puts '', 'RECENT'
36 pp Delicious.new(config['username'], config['password']).recent
37
Something went wrong with that request. Please try again.