Skip to content
Newer
Older
100644 39 lines (32 sloc) 1.2 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 format :xml
10
3a8ad1d @jnunemaker Added :basic_auth as an option key when making a request. [#1 state:r…
authored
11 def initialize(u, p)
12 @auth = {:username => u, :password => p}
99cd89d @jnunemaker added delicious example and tweaked the twitter example
authored
13 end
14
15 # query params that filter the posts are:
16 # tag (optional). Filter by this tag.
17 # dt (optional). Filter by this date (CCYY-MM-DDThh:mm:ssZ).
18 # url (optional). Filter by this url.
19 # ie: posts(:query => {:tag => 'ruby'})
20 def posts(options={})
3a8ad1d @jnunemaker Added :basic_auth as an option key when making a request. [#1 state:r…
authored
21 options.merge!({:basic_auth => @auth})
aafde86 @jnunemaker Documented and tweaked the examples a bit.
authored
22 # get posts and convert to structs so we can do .key instead of ['key'] with results
3a8ad1d @jnunemaker Added :basic_auth as an option key when making a request. [#1 state:r…
authored
23 self.class.get('/posts/get', options)
99cd89d @jnunemaker added delicious example and tweaked the twitter example
authored
24 end
25
26 # query params that filter the posts are:
27 # tag (optional). Filter by this tag.
28 # count (optional). Number of items to retrieve (Default:15, Maximum:100).
29 def recent(options={})
3a8ad1d @jnunemaker Added :basic_auth as an option key when making a request. [#1 state:r…
authored
30 options.merge!({:basic_auth => @auth})
31 self.class.get('/posts/recent', options)
99cd89d @jnunemaker added delicious example and tweaked the twitter example
authored
32 end
33 end
34
aafde86 @jnunemaker Documented and tweaked the examples a bit.
authored
35 delicious = Delicious.new(config['username'], config['password'])
36 pp delicious.posts(:query => {:tag => 'ruby'})
37 pp delicious.recent
99cd89d @jnunemaker added delicious example and tweaked the twitter example
authored
38
Something went wrong with that request. Please try again.