Posted By

felipec on 04/15/07


Tagged

web20 delicious


Versions (?)



Who likes this?

3 people have marked this snippet as a favorite

sergeizen
RhetTbull
webstic


Ruby del.icio.us


Published in: Ruby 



Website Promotion
DIRECTORY
is a crucial factor for all websites that need to gain better organic search engine rankings and increase website traffic.
Submitting your website as part of your Web Promotion strategy to our SEO friendly and high traffic Business Directory for review is an excellent way to gain a valuable backlink and increase your websites visibility online.

Submit Site


Provides a little bit of functionality to access del.icio.us bookmarks.

Expand | Embed | Plain Text
  1. require 'rest'
  2. require 'rexml/document'
  3.  
  4. module Diu
  5. URL = "https://api.del.icio.us/v1/"
  6.  
  7. class Connection
  8. def initialize(username, password)
  9. @conn = REST::Connection.new(URL, :username => username, :password => password)
  10. @posts = Posts.new(@conn)
  11. end
  12.  
  13. attr_reader :posts
  14. end
  15.  
  16. class Posts
  17. class Post
  18. def initialize(xml_item)
  19. @href = xml_item.attributes["href"]
  20. @time = xml_item.attributes["time"]
  21. @hash = xml_item.attributes["hash"]
  22. @tag = xml_item.attributes["tag"]
  23. @description = xml_item.attributes["description"]
  24. @extended = xml_item.attributes["extended"]
  25. end
  26.  
  27. attr_reader :href, :time, :hash, :tag, :description, :extended
  28. end
  29.  
  30. def initialize(conn)
  31. @conn = conn
  32. end
  33.  
  34. def find(method, args = nil)
  35. resource = "posts/%s" % [method]
  36. request = @conn.request_get(resource, args)
  37.  
  38. posts = Array.new
  39. doc = REXML::Document.new(request)
  40. doc.elements.each("//post") do |xml_post|
  41. posts << Post.new(xml_post)
  42. end
  43. posts
  44. end
  45. end
  46. end

Report this snippet 

You need to login to post a comment.