bcolas
07/09/2007, 08h37
Bonjour,
développant un site avec intégration à des web services externes à mon site, je réussis à utiliser parfaitement les fonctions curl_init, curl_exec, ... en intéractif, ie dans des pages PHP.
J'ai besoin pour des traitements un peu plus long que j'aimerais exécuter sous forme de taches programmées. J'utilise exactement la même classe dans les deux cas bien sûr et j'obtiens l'erreur CURL suivante:
CURLE_COULDNT_CONNECT (7) : Failed to connect() to host or proxy.
Je vous joins le bout de code qui effectue la connexion:
//build headers using variables passed via constructor
$headers = $this->buildHeaders();
//initialise a CURL session
$connection = curl_init();
//set the server we are using (could be Sandbox or Production server)
curl_setopt($connection, CURLOPT_URL, $this->serverUrl);
//stop CURL from verifying the peer's certificate
curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 0);
//set the headers using the array of headers
curl_setopt($connection, CURLOPT_HTTPHEADER, $headers);
//set method as POST
curl_setopt($connection, CURLOPT_POST, 1);
//set the XML body of the request
curl_setopt($connection, CURLOPT_POSTFIELDS, $requestBody);
//set it to return the transfer as a string from curl_exec
curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
//Send the Request
$response = curl_exec($connection);
//close the connection
curl_close($connection);
Je vous remercie pour votre aide.
Benoit
développant un site avec intégration à des web services externes à mon site, je réussis à utiliser parfaitement les fonctions curl_init, curl_exec, ... en intéractif, ie dans des pages PHP.
J'ai besoin pour des traitements un peu plus long que j'aimerais exécuter sous forme de taches programmées. J'utilise exactement la même classe dans les deux cas bien sûr et j'obtiens l'erreur CURL suivante:
CURLE_COULDNT_CONNECT (7) : Failed to connect() to host or proxy.
Je vous joins le bout de code qui effectue la connexion:
//build headers using variables passed via constructor
$headers = $this->buildHeaders();
//initialise a CURL session
$connection = curl_init();
//set the server we are using (could be Sandbox or Production server)
curl_setopt($connection, CURLOPT_URL, $this->serverUrl);
//stop CURL from verifying the peer's certificate
curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 0);
//set the headers using the array of headers
curl_setopt($connection, CURLOPT_HTTPHEADER, $headers);
//set method as POST
curl_setopt($connection, CURLOPT_POST, 1);
//set the XML body of the request
curl_setopt($connection, CURLOPT_POSTFIELDS, $requestBody);
//set it to return the transfer as a string from curl_exec
curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
//Send the Request
$response = curl_exec($connection);
//close the connection
curl_close($connection);
Je vous remercie pour votre aide.
Benoit