Empecher une redirection avec cURL

matriel -  
 matriel -
Bonjour,


Je decouvre progressivement cURL et je me retrouve face a un probleme que je n'arrive pas a contourner :
J'essaye d'acceder a un site https via cURL mais lors de l'authentification il me redirige vers une page une page de validation. Au final je suis bien connecter mais pas via cURL, ce qu'y m'empeche donc de poursuivre la navigation avec mon script pour recuperer les données dont j'ai besoin.

SI quelqu'un a une petite piste a me presenter, je suis toute ouie ^^

et voici mon morceau de code, si vous y voyez une erreur.
<?php 
PostFormulaire();
      function PostFormulaire() 
      {
           $url = 'https://secure.celeste.fr/espace-client-v2/index/login';
      $postfield=array();
      $postfield['log'] = '*****';
      $postfield['pwd'] = '*****';
      $postfield['rememberme'] = 'On';

      $path_cookie = 'connexion_Celeste.txt';
      if (!file_exists(realpath($path_cookie))) touch($path_cookie);

      $curl = curl_init();
      curl_setopt($curl, CURLOPT_URL, "$url");
      curl_setopt($curl, CURLOPT_COOKIESESSION, true);
      curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
      curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($curl, CURLOPT_POST, 1);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $postfield);
      curl_setopt($curl, CURLOPT_REFERER, $url);
      curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 0);
      curl_setopt($curl, CURLOPT_COOKIEJAR, realpath($path_cookie));
      $return = curl_exec($curl);

      $url = 'http://espace-client-v2.celeste.fr/';
      curl_setopt($curl, CURLOPT_URL, "$url");
      curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
      curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($curl, CURLOPT_COOKIEJAR, realpath($path_cookie));
      $return = curl_exec($curl);

      $source=$url;

      $url = 'https://secure.celeste.fr/espace-client-v2/';
      curl_setopt($curl, CURLOPT_URL, "$url");
      curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
      curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($curl, CURLOPT_REFERER, $source);
      curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
      curl_setopt($curl, CURLOPT_HEADER, 1);
      curl_setopt($curl, CURLOPT_COOKIEJAR, realpath($path_cookie));
      $return = curl_exec($curl);
     
      curl_close($curl);
      unlink($path_cookie);
      
      echo $return;
      }
?>

1 réponse

matriel
 
je n'ai toujours pas trouver de solution donc si quelqu'un pouvais me donner un petit coup de pouce, ca m'aiderai vraiment x)
0