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.
If you are using a Debian based GNU/Linux distribution, it can be installed using the following command as root:
# apt-get install curl
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
curlto 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 use
grepto 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…