Now we will try to explain you how to know the destiny URL of an shortened URL, like used in Twitter and other social networks, using cURL (Curl)
¿What is cURL?
Curl is a command line tool and a library that allows you to make network request using URL syntax, it supports the more common protocols, like http, https, ftp, etc. It is avalible as librery and as command line tool, so we can execute it directly or use it form our source code. It is also available for PHP.
This is a translated version of the original Spanish post, so please be patient and tell me all mistakes you find.
Thanks you.
Installation
If you are using a Debian based GNU/Linux distribution, it can be installed using the following command as root:
# apt-get install curl
Testing
To do it, type the folowing command on your terminal and you will get the real destiny of the shortened URL:
$ curl -sLI http://shortened_url | grep -i Location
The option “s” tells to
curl
to be silent, so will not print the “download” progress, “L” option tells that Curls must follow all redirections and “I” to download only the HTTP header, that is all we need. Lastly, we usegrep
to get header line that have redirection URL.
As an example we have taken a “GNU Social” shortened URL and this was the result:
And it is all by now, we hope it will be useful for you…
a tech writer
I didn’t know that was possible. It probably won’t work for those short urls with an ad wall.
Elías R.M.
Yes, you are right. This trick is based on the fact that the shortened URL normally do a redirect, so we can easily “capture the redirection”.