Pour le Curl, j’utilisai :
$ch = curl_init(trim($src));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); // Utilise TLS 1.2
$content = curl_exec($ch);
curl_close($ch);
J’ai essayé avec :
set_time_limit(0); // no script timeout
// Importation
$rowdatas_temp_file = __DIR__.'datas.temp';
SyndicationbaseModel::$GlobalFileHandle = fopen($rowdatas_temp_file, 'w+');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, trim($src));
curl_setopt($ch, CURLOPT_FILE, SyndicationbaseModel::$GlobalFileHandle);
curl_setopt($ch,CURLOPT_ENCODING , 'gzip');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'SyndicationbaseModel::captureHeader');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_TIMEOUT, -1);
curl_setopt($ch, CURLOPT_VERBOSE, false);
curl_setopt($ch, CURLOPT_WRITEFUNCTION, 'SyndicationbaseModel::curlWriteFile');
$curlResponse = curl_exec($ch);
// Gestion des erreurs
if( $curlResponse === false) {
$reponses[] = 'Erreur Curl : ' . curl_error($ch);
} else {
$reponses[] = 'Le téléchargement s\'est terminé sans aucune erreur';
}
.....
....
...
public static function curlWriteFile($cp, $data) {
$len = fwrite(SyndicationbaseModel::$GlobalFileHandle, $data);
return $len;
}
public static function captureHeader($ch, $headerData){
if (substr($headerData, 0, 4) == 'HTTP'){
SyndicationbaseModel::$curlStatus = substr($headerData, 9, 3);
}
else if (false !== strpos($headerData, ':')){
list($header, $content) = explode(':', $headerData, 2);
//Normalize the header name
$header = SyndicationbaseModel::normalize($header);
$content = trim($content);
SyndicationbaseModel::$curlHeaders[$header] = $content;
}
return strlen($headerData);
}
public static function normalize($header){
return ucfirst(strtolower(trim($header)));
}
Mais pas mieux, toujours erreur 504 Gateway Timeout.
$src = "https://diffuseur.datatourisme.fr/webservice/4f94b20237c3db6947d19dbcd801150a/xxxxxxxxxxxx";
IP du serveur est :
213.186.33.xx
2001:41d0:1:1b00:213:186:xxx