Invité Posté 25 Septembre 2007 Partager Posté 25 Septembre 2007 bonjour, je cherche une classe ou une librairie qui, à partir d'une URL de redirection, me permet d'obtenir le lien "final", que ce soit une redirection permanente (301) ou temporaire (302), ou autre. un peu à la manière des Tools de WRI ou Webmaster-Hub qui proposent via leurs interfaces respectives d'obtenir les entêtes HTTP, et ce, jusqu'à 8 redirections successives. Je n'arrive pas à trouver ça. Merci Lien vers le commentaire Partager sur d’autres sites More sharing options...
Anonymus Posté 25 Septembre 2007 Partager Posté 25 Septembre 2007 Pour avoir juste le premier header retourné, tu peux utiliser ceci : <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.google.com"); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($ch); curl_close($ch);echo"<pre>";echo substr($data,0,strpos($data,"\n\r"));die(""); Pour avoir tous les headers, t'as 2 solutions : Soit tu fais une boucle à partir de ce morceau de programme, Soit tu récupères toute la page : <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.google.com"); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($ch); curl_close($ch);echo"<pre>";print_r($data);die(""); Nico. Lien vers le commentaire Partager sur d’autres sites More sharing options...
Invité Posté 25 Septembre 2007 Partager Posté 25 Septembre 2007 Nickel ! je vais essayer cette solution :thumbsup: Dis moi, j'ai cherché toute la journée sans trouver. Tu l'as trouvé comment toi ? Lien vers le commentaire Partager sur d’autres sites More sharing options...
Sujets conseillés
Veuillez vous connecter pour commenter
Vous pourrez laisser un commentaire après vous êtes connecté.
Connectez-vous maintenant