ca4kca
Last Updated: February 25, 2016
·
9.951K
· projectcleverweb
Big pimpin

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.

Say Thanks
Respond