Skip to content

Instantly share code, notes, and snippets.

@2GMon
Created December 16, 2011 07:21
Show Gist options
  • Save 2GMon/1484947 to your computer and use it in GitHub Desktop.
Save 2GMon/1484947 to your computer and use it in GitHub Desktop.
instapaperにURLを登録する
# instapaperにURLを登録する
require 'net/http'
require 'cgi'
url = CGI.escape(ARGV[0])
username = CGI.escape(ARGV[1])
password = CGI.escape(ARGV[2])
post = ""
if password == nil
post = "username=#{username}&url=#{url}"
else
post = "username=#{username}&password=#{password}&url=#{url}"
end
https = Net::HTTP.new('www.instapaper.com', 443)
https.use_ssl = true
res = https.post('/api/add', post)
print "response code : #{res.code}\n"
res.each {|key, value|
print key.to_s + " : " + value.to_s
puts ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment