Problème CURL sur Linux
Posté : 29 août 2016, 10:04
Bonjour à tous,
Je suis en train de développer un petit script CURL / PHP qui, pour l'instant, permet de se connecter à une plateforme via Login et mot de passe. Problème: Cela fonctionne très bien sur Windows; par contre, cela ne fonctionne pas sur Linux. Savez-vous pourquoi ? Je me tire les cheveux depuis 3 heures à essayer de comprendre comment quelque chose peut fonctionner sur Windows mais pas sur Linux.
Merci à tous pour votre aide
A noter que si j'enlève le connecttimeout, cela me retourne le code d'erreur 7 et le message "couldn't connect to host". De même, si je teste une requête minimaliste (comme ci-dessous), même résultat
J'ai testé une requête GET avec d'autres pages du site, toujours pareil. Je pense qu'il y a quelque chose qui bloque les requêtes mais impossible de trouver quoi.
Je suis en train de développer un petit script CURL / PHP qui, pour l'instant, permet de se connecter à une plateforme via Login et mot de passe. Problème: Cela fonctionne très bien sur Windows; par contre, cela ne fonctionne pas sur Linux. Savez-vous pourquoi ? Je me tire les cheveux depuis 3 heures à essayer de comprendre comment quelque chose peut fonctionner sur Windows mais pas sur Linux.
Merci à tous pour votre aide
Code : Tout sélectionner
/* Identification */
$urlLogin = URL_LOGIN;
$postField = array(
'username' => LOGIN,
'password' => PASSWORD,
'remember' => 'on',
);
$this->_curl = curl_init($urlLogin);
curl_setopt($this->_curl, CURLOPT_FRESH_CONNECT, true);
curl_setopt($this->_curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($this->_curl, CURLOPT_POST, true);
curl_setopt($this->_curl, CURLOPT_POSTFIELDS, $postField);
curl_setopt($this->_curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->_curl, CURLOPT_COOKIE, true);
curl_setopt($this->_curl, CURLOPT_COOKIEJAR, COOKIE_FILE);
curl_setopt($this->_curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($this->_curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($this->_curl, CURLOPT_TIMEOUT, 240);
curl_setopt($this->_curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:48.0) Gecko/20100101 Firefox/48.0');
$result = curl_exec($this->_curl);
$codeError = curl_errno($this->_curl);
$msgError = curl_error($this->_curl);
curl_close($this->_curl);
Code : Tout sélectionner
/* Identification */
$urlLogin = URL_LOGIN;
$this->_curl = curl_init($urlLogin);
curl_setopt($this->_curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($this->_curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->_curl, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($this->_curl);
$codeError = curl_errno($this->_curl);
$msgError = curl_error($this->_curl);
curl_close($this->_curl);