Here is a long method
This has very little error handling, but it can help you get started. You can wrap the extension with a disaster recovery unit that returns zero or will try again later. Not sure what you are trying to build, but hope this helps.
require 'uri' require 'net/http' def lengthen(url) uri = URI(url) Net::HTTP.new(uri.host, uri.port).get(uri.path).header['location'] end irb(main):008:0> lengthen('http://bit.ly/l223ue') => "http://paper.li/CoyDavidsonCRE/1309121465"
source share