<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jabbering Giraffe &#187; delicious</title>
	<atom:link href="http://happygiraffe.net/blog/tag/delicious/feed/" rel="self" type="application/rss+xml" />
	<link>http://happygiraffe.net/blog</link>
	<description></description>
	<lastBuildDate>Tue, 07 Feb 2012 20:49:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>del.icio.us api change</title>
		<link>http://happygiraffe.net/blog/2006/08/11/del-icio-us-api-change/</link>
		<comments>http://happygiraffe.net/blog/2006/08/11/del-icio-us-api-change/#comments</comments>
		<pubDate>Fri, 11 Aug 2006 08:59:00 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[delicious]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/2006/08/11/del-icio-us-api-change/</guid>
		<description><![CDATA[I&#8217;ve just been caught out by the del.icio.us api change (they&#8217;ve just switched off the old api). This broke the backup script I use. It&#8217;s a nice script, it downloads each days bookmarks into a sqlite database, ready for reuse. &#8230; <a href="http://happygiraffe.net/blog/2006/08/11/del-icio-us-api-change/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just been caught out by the <a href="http://blog.del.icio.us/blog/2006/05/feel_secure.html">del.icio.us api change</a> (they&#8217;ve just switched off the old api).  This broke the <a href="http://www.bigbold.com/snippets/posts/show/290">backup script</a> I use.  It&#8217;s a nice script, it downloads each days bookmarks into a sqlite database, ready for reuse.</p>
<p>Anyway, this is the patch I wrote to make it use the new api (over <span class="caps">SSL</span>) instead.  <span class="caps">BTW</span>, top marks to the del.icio.us people for using basic auth instead of coming up with their own scheme.  Basic auth + <span class="caps">SSL</span> is a really nice, simple way of doing things.</p>
<pre>
  --- /home/dom/delicious-backup.rb.orig    Fri Aug 11 09:00:39 2006
  +++ /home/dom/bin/delicious-backup.rb    Fri Aug 11 09:09:19 2006
  @@ -26,11 +32,29 @@
                'values (?, ?, ?, ?, ?);'
   insert_tag = 'insert into tags (hash, tag) values (?, ?);'

  -xml = Net::HTTP.start('del.icio.us') { |http|
  -    req = Net::HTTP::Get.new('/api/posts/all', {'User-Agent' =&gt; agent})
  +# https://api.del.icio.us/v1/posts/get
  +require 'net/https'
  +http = Net::HTTP.new('api.del.icio.us', 443)
  +http.use_ssl = true
  +http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  +xml = http.start { |conn|
  +    req = Net::HTTP::Get.new('/v1/posts/all', {'User-Agent' =&gt; agent})
       req.basic_auth(user, pass)
  -    http.request(req).body
  +    resp = conn.request(req)
  +    raise resp.inspect unless resp.kind_of? Net::HTTPSuccess
  +    resp.body
   }
  +
  +Dir.chdir(ARGV[1] || ENV['HOME'] + '/libdata/del.icio.us')
  +
  +# Clean anything over 30 days.
  +thirty_days_ago = Time.now - (30 *(24*60*60))
  +Dir["*.db"].each do |name|
  +    f = File.new(name)
  +    if f.mtime &lt; thirty_days_ago
  +        File.unlink(name)
  +    end
  +end

   db_name = ARGV[0] || Time.now.strftime("%Y-%m-%d.db")
   SQLite3::Database.open(db_name).transaction { |db|
</pre>
<p>That&#8217;s also got my backup expiry bits in, which is handy, but could probably be done better.  <span class="caps">BTW</span>, that ruby idiom of indexing the Dir class to run a glob is <em>freakish</em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/08/11/del-icio-us-api-change/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

