/ Published in: Ruby
Place script into Automator (select "Run Shell Script" choose /usr/bin/ruby as the shell).
You'll need to create a bit.ly account which will give you your API key for authentication.
You'll need to create a bit.ly account which will give you your API key for authentication.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/usr/bin/env ruby require 'uri' require 'net/http' uri = STDIN.gets(nil).strip.delete("\n\r") unless uri.empty? begin escaped_uri = URI.escape("http://api.bit.ly/v3/shorten?login=yourlogin&apiKey=yourapikey&longUrl=#{uri}&format=txt") STDOUT << Net::HTTP.get_response(URI.parse(escaped_uri)).body rescue URI::InvalidURIError # Do nothing. end end