Saturday, 17 August 2013

How to get true address of a shortened URL in PHP?

How to get true address of a shortened URL in PHP?

Is there any way that I can get the URL pointed by another (shortened) URL ?
For example, I have shortened http://www.stackoverflow.com to this URL :
http://tinyurl.com/5b2su2
so I need a function in PHP like
getTrueURL($shortened_url)
{
// ?
}
which returns 'http://stackoverflow.com' when
getTrueURL('http://tinyurl.com/5b2su2') is called.
How can I do this?
Thanks in advance.
P.S: If it is impossible in server-side, I can also use a JavaScript
solution as well.

No comments:

Post a Comment