Recommended:

  • phpclasses.org
  • jsclasses.org
  • jsmag.com
  • siteapps.com
  • View our reviews on Hot Scripts
  • JS Tutorial
  • scripts.com
  • securesignup.com




Recent Comments

Powered by Disqus




Back to articles

is.gd API to shorten your links

There is a website http://is.gd/ that allows you to shorten you links. To do it, you can use this function:

<?php
function get_url($url)
{ 
    //checking if curl is available
    if(in_array  ('curl', get_loaded_extensions())) 
    {
        $ch = curl_init();  
        $timeout = 5;  
        curl_setopt($ch,CURLOPT_URL,'http://is.gd/api.php?longurl='.$url);  
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);  
        curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);  
        $short = curl_exec($ch);  
        curl_close($ch);
    }
    else
    {
        $short = file_get_contents('http://is.gd/api.php?longurl='.$url);
    }
    return $short;  
} 
?>

You may also be interested in:

Powered by BlogAlike.com

blog comments powered by Disqus