//gets the data from a URL
function get_tiny_url($url)
{
$ch = curl_init();
$timeout = 5; //Depend on you
curl_setopt($ch,CURLOPT_URL,'http://tinyurl.com/api-create.php?url='.$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$newUr = curl_exec($ch);
curl_close($ch);
return $newUr;
}
//test it out!
$newUrl = get_tiny_url('http://anyurl.com');
//returns http://tinyurl.com/randomUrl
echo $newUrl