Ich arbeite gerade an einem kleinen Tool, fuer das ich den URL-Kuerzungsdienst bit.ly ansprechen wollte. Daher habe ich mir eine Ruby-Klasse dafuer geschrieben, die die RESTfull-API anspricht:
#!/usr/bin/env ruby
# client class for url shortening service bit.ly
require 'net/http'
require 'uri'
class Bitly
def self.shortURL(surl)
api_url = "http://bit.ly/api"
res = Net::HTTP.post_form(URI.parse(api_url),{'url'=> surl})
return res.body
end
end
# Possible usage
puts Bitly.shortURL("http://blog.roothausen.de")
Das Ergebnis schaut so aus:
./bitlyapi.rb http://bit.ly/2BTVbK
Trackbacks
Trackback specific URI for this entry
No Trackbacks
Comments
Display comments as
(Linear | Threaded)
ruby ist echt nicht meine welt. das sieht ja schlimm aus =)
Also das ist definitiv Geschmackssache. Mir gefaellt ruby bisher sehr gut.
Quicksearch
Kategorien
Tags
android bad world blog blogging browser changes code comic computer contentmanagement encryption feedreader firefox free fun google gui hardware howto html im jabber java life lighttpd linux linux&unix markup media misc mobile murphy networking newsbeuter opensource picture politics presentation privacy programming regular expression rss ruby s9y scala screenshot sdk security server shortys software stuff tail -f /var/log/life test tool tv unix video web webdesign webwide windows xml zeitgeist


