(PHP 4 >= 4.0.2, PHP 5)
Raccourci une URL avec le service is.gd URL Shortener.
<?php
function make_isdg_url($url)
{
$parse_url = parse_url($url);
if( empty($parse_url['scheme']) ) return FALSE;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://is.gd/api.php?longurl='.urlencode($url));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$content = curl_exec($ch);
curl_close($ch);
if( strpos($content, 'http') === FALSE )
return FALSE;
return trim($content);
}
?>
string make_isgd_url ( string $url )
Retourne l'URL raccourcie ou FALSE si une erreur est survenue.
Exemple #1 Exemple avec make_isgd_url()
<?php $url = "http://seebz.net/"; $url = make_isgd_url($url); echo $url; // http://is.gd/6snIE ?>
Commentaire(s)
Poster un commentaire