Quick and painless Tiny URL generator
Given you don't want to have to take the time to setup a URL shortening system, here is a short script to use tinyurl.com's system.
<?php
function tinyurl_gen($url) {
if(filter_var($url,FILTER_SANITIZE_URL)){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,'http://tinyurl.com/api-create.php?url='.$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,5);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
else{
return false;
}
}
Thanks for reading
If you enjoyed what I wrote, consider upvoting this protip or endorsing me.
If you want to see more of my stuff, you can see other protips I have written or visit my profile.
Written by Nicholas Jordon
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#