Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 37 lines (31 sloc) 1.189 kB
99cd89d @jnunemaker added delicious example and tweaked the twitter example
authored
1 dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
1d48da0 @jnunemaker Renamed to HTTParty which is way more fun and unique than boring old …
authored
2 require File.join(dir, 'httparty')
99cd89d @jnunemaker 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 @jnunemaker Renamed to HTTParty which is way more fun and unique than boring old …
authored
7 include HTTParty
99cd89d @jnunemaker added delicious example and tweaked the twitter example
authored
8 base_uri 'https://api.del.icio.us/v1'
9
3a8ad1d @jnunemaker Added :basic_auth as an option key when making a request. [#1 state:r…
authored
10 def initialize(u, p)
11 @auth = {:username => u, :password => p}
99cd89d @jnunemaker added delicious example and tweaked the twitter example
authored
12 end
13
14 # query params that filter the posts are:
15 # tag (optional). Filter by this tag.
16 # dt (optional). Filter by this date (CCYY-MM-DDThh:mm:ssZ).
17 # url (optional). Filter by this url.
18 # ie: posts(:query => {:tag => 'ruby'})
19 def posts(options={})
3a8ad1d @jnunemaker Added :basic_auth as an option key when making a request. [#1 state:r…
authored
20 options.merge!({:basic_auth => @auth})
21 self.class.get('/posts/get', options)
99cd89d @jnunemaker added delicious example and tweaked the twitter example
authored
22 end
23
24 # query params that filter the posts are:
25 # tag (optional). Filter by this tag.
26 # count (optional). Number of items to retrieve (Default:15, Maximum:100).
27 def recent(options={})
3a8ad1d @jnunemaker Added :basic_auth as an option key when making a request. [#1 state:r…
authored
28 options.merge!({:basic_auth => @auth})
29 self.class.get('/posts/recent', options)
99cd89d @jnunemaker added delicious example and tweaked the twitter example
authored
30 end
31 end
32
aafde86 @jnunemaker Documented and tweaked the examples a bit.
authored
33 delicious = Delicious.new(config['username'], config['password'])
34 pp delicious.posts(:query => {:tag => 'ruby'})
4113408 @jnunemaker Fixed weird uri normalizing issue that occurred when I was doing norm…
authored
35 pp delicious.recent
99cd89d @jnunemaker added delicious example and tweaked the twitter example
authored
36
3953ead @jnunemaker Updated history and examples.
authored
37 delicious.recent['posts']['post'].each { |post| puts post['href'] }
Something went wrong with that request. Please try again.