This snippet helps you to shorten your URLs with TinyURL API(Function with usage)
- <?php
- function TinyURL($url){
- return file_get_contents('http://tinyurl.com/api-create.php?url='.$url);
- }
- echo TinyURL('http://www.ultimateprogrammingtutorials.info');
- ?>
You need to replace http://www.ultimateprogrammingtutorials.info with the URL you want to shorten
1 comments:
Thanks.. much cleaner than:
Reply$ch = curl_init();
$timeout = 5;
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);
$data = curl_exec($ch);
curl_close($ch);
return $data;
Post a Comment
Note: Only a member of this blog may post a comment.