SHARE
TWEET

Sam Joseph

a guest Sep 14th, 2010 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/ruby
  2. # delicious-wadl-ruby.rb
  3. require 'wadl'
  4.  
  5. if ARGV.size != 2
  6.   puts "Usage: #{$0} [username] [password]"
  7.   exit
  8. end
  9. username, password = ARGV
  10.  
  11. # Load an application from the WADL file
  12. delicious = WADL::Application.from_wadl(open("delicious.wadl"))
  13.  
  14. # Give authentication information to the application
  15. service = delicious.v1.with_basic_auth(username, password)
  16.  
  17. begin
  18.   # Find the "recent posts" functionality
  19.   recent_posts = service.posts.recent
  20.  
  21.   # For every recent post...
  22.   recent_posts.get.representation.each_by_param('post') do |post|
  23.     # Print its description and URI.
  24.     puts "#{post.attributes['description']}: #{post.attributes['href']}"
  25.   end
  26. rescue WADL::Faults::AuthorizationRequired
  27.   puts "Invalid authentication information!"
  28. end
RAW Paste Data
Want to get better at Ruby?
Learn to code Ruby in 2017
Top