Sha256: fd44e00df87db24d187e7b4cd5c59207bebf9ae5e30e21b81d52070de10dccbf

Contents?: true

Size: 1.16 KB

Versions: 120

Compression:

Stored size: 1.16 KB

Contents

dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
require File.join(dir, 'httparty')
require 'pp'
config = YAML::load(File.read(File.join(ENV['HOME'], '.delicious')))

class Delicious
  include HTTParty
  base_uri 'https://api.del.icio.us/v1'
  
  def initialize(u, p)
    @auth = {:username => u, :password => p}
  end
  
  # query params that filter the posts are:
  #   tag (optional). Filter by this tag.
  #   dt (optional). Filter by this date (CCYY-MM-DDThh:mm:ssZ).
  #   url (optional). Filter by this url.
  #   ie: posts(:query => {:tag => 'ruby'})
  def posts(options={})
    options.merge!({:basic_auth => @auth})
    self.class.get('/posts/get', options)
  end
  
  # query params that filter the posts are:
  #   tag (optional). Filter by this tag.
  #   count (optional). Number of items to retrieve (Default:15, Maximum:100).
  def recent(options={})
    options.merge!({:basic_auth => @auth})
    self.class.get('/posts/recent', options)
  end
end

delicious = Delicious.new(config['username'], config['password'])
pp delicious.posts(:query => {:tag => 'ruby'})
pp delicious.recent

delicious.recent['posts']['post'].each { |post| puts post['href'] }

Version data entries

120 entries across 120 versions & 24 rubygems

Version Path
alexvollmer-httparty-0.3.1 examples/delicious.rb
alexvollmer-httparty-0.4.3 examples/delicious.rb
cluon-httparty-0.4.3 examples/delicious.rb
dbalatero-httparty-0.4.4 examples/delicious.rb
ddollar-httparty-0.4.6 examples/delicious.rb
geetarista-httparty-0.4.5 examples/delicious.rb
jcinnamond-httparty-0.4.5 examples/delicious.rb
jcinnamond-httparty-0.4.6 examples/delicious.rb
jnunemaker-httparty-0.2.10 examples/delicious.rb
jnunemaker-httparty-0.2.9 examples/delicious.rb
jnunemaker-httparty-0.3.0 examples/delicious.rb
jnunemaker-httparty-0.3.1 examples/delicious.rb
jnunemaker-httparty-0.4.0 examples/delicious.rb
jnunemaker-httparty-0.4.1 examples/delicious.rb
jnunemaker-httparty-0.4.2 examples/delicious.rb
jnunemaker-httparty-0.4.3 examples/delicious.rb
jnunemaker-httparty-0.4.4 examples/delicious.rb
jnunemaker-httparty-0.4.5 examples/delicious.rb
kerryb-httparty-0.3.2 examples/delicious.rb
kerryb-httparty-0.3.3 examples/delicious.rb