私が試したこと/試していること
function download_data($target_document,$outfile_location)
{
log_message('info', 'Downloading every page in data set');
do
{
$ch = curl_init ($target_document.'apiKey=' . self::$API_KEY);
$fp = fopen($outfile_location . "data.zip", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
fclose($fp);
$this->http_status = $http_status;
if($this->http_status != 200)
{
$this->data_retry_count += 1;
}
} while($this->http_status != 200 && $this->data_retry_count < $this->retry_max);
if($this->http_status == 200)
{
return;
}
}
上記のコードを使用すると、内容のない圧縮(zip)を取得する以外は、すべてがスムーズに進みます。ブラウザにターゲットドキュメントをダウンロードすると、機能します。zipファイルの内容を取得するためにcurlで何か別のことをする必要がありますか?
$this
この関数はクラスの一部であり、これらの変数はクラス内に含まれる変数を表すため、変数は無視してください。