Skip to content

Instantly share code, notes, and snippets.

@trevorturk
Created January 13, 2011 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trevorturk/777224 to your computer and use it in GitHub Desktop.
Save trevorturk/777224 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'httparty'
task :pinboard do
class Pinboard
include HTTParty
base_uri 'https://api.pinboard.in/v1'
def initialize(auth)
@auth = auth
end
def recentPosts(options={})
apiData = { :basic_auth=>@auth }
apiData.merge!(options)
self.class.get('/posts/recent?count=100', apiData)
end
end
pinboard = Pinboard.new(:username=>'trevorturk', :password=>'password')
links = pinboard.recentPosts['posts']['post']
body = ''
links.each do |l|
body << "<p><a href=\"#{l['href']}\">#{l['description']}</a></p>\n"
body << "<blockquote><p>#{l['extended'].chomp}</p></blockquote>\n\n"
end
puts body
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment