Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the destination URL of a shortened URL using Ruby?

How do I take this URL http://t.co/yjgxz5Y and get the destination URL which is http://nickstraffictricks.com/4856_how-to-rank-1-in-google/

like image 905
Nick Avatar asked Apr 03 '11 20:04

Nick


1 Answers

require 'net/http'
require 'uri'

Net::HTTP.get_response(URI.parse('http://t.co/yjgxz5Y'))['location']
# => "http://nickstraffictricks.com/4856_how-to-rank-1-in-google/" 
like image 174
Mladen Jablanović Avatar answered Oct 18 '22 12:10

Mladen Jablanović