Dernière mise à jour: ven 19 fév 2010

make_isgd_url()

(PHP 4 >= 4.0.2, PHP 5)

Raccourci une URL avec le service is.gd URL Shortener.

Source

<?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);
}

?>

Syntaxe

string make_isgd_url ( string $url )

Arguments

  1. url - L'URL à raccourcir.

Valeurs de retour

Retourne l'URL raccourcie ou FALSE si une erreur est survenue.

Exemples

Exemple #1 Exemple avec make_isgd_url()

<?php

$url = "http://seebz.net/";
$url = make_isgd_url($url);
echo $url; // http://is.gd/6snIE

?>

Voir aussi

Commentaire(s)

Il n'y a aucun commentaire pour cette page.

Poster un commentaire