Resolving a tinyURL to destination URL
1 2 < ?php 3 4 // request like this http://<domain>/tinyurl.php?c=<tinyurl> 5 6 $num = $_GET['c']; 7 8 if($fp = fsockopen ("tinyurl.com", 80, $errno, $errstr, 30)) 9 { 10 if ($fp) { 11 fputs ($fp, "HEAD /$num HTTP/1.0\r\nHost: tinyurl.com\r\n\r\n"); 12 while (!feof($fp)) {$headers .= fgets ($fp,128);} 13 fclose ($fp); 14 } 15 $arr1=explode("Location:",$headers); 16 $arr=explode("\n",trim($arr1[1])); 17 echo trim($arr[0]); 18 } 19 ?>
http://www.webforth.com/2007/07/resolving-tinyurls-to-the-desination-url