(PHP 4 >= 4.0.2, PHP 5)
Raccourci une URL avec le service u.nu URL Shortener.
<?php function make_unu_url($url) { $parse_url = parse_url($url); if( empty($parse_url['scheme']) ) return FALSE; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://u.nu/unu-api-simple?url='.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_unu_url ( string $url )
Retourne l'URL raccourcie ou FALSE si une erreur est survenue.
Exemple #1 Exemple avec make_unu_url()
<?php $url = "http://seebz.net/"; $url = make_unu_url($url); echo $url; // http://u.nu/743k4 ?>
Commentaire(s)
Poster un commentaire