Reverse TinyURL
Join the DZone community and get the full member experience.
Join For Free
PHP
// Resolves a TinyURL.com encoded URL to its source.
// Example: reverse_tinyurl('http://tinyurl.com/2ocfun') => "http://logankoester.com"
function reverse_tinyurl($url) {
$url = explode('.com/', $url);
$url = 'http://preview.tinyurl.com/' . $url[1];
$preview = file_get_contents($url);
preg_match('/redirecturl" href="(.*)">/', $preview, $matches);
return $matches[1];
}
API
Design
Snippet (programming)
Template
Opinions expressed by DZone contributors are their own.
Comments