こんにちは、以下のコードを使用してダウンロードし、サーバーから .zip ファイルを取得しています。ファイルは取得していますが、同じ php ファイル内のフォルダーに解凍しようとしていますが、スクリプトを実行するとファイルがダウンロードされます。 、これは私が得る出力です:
これは私が得る出力です:
File Opening Successful
Warning: ZipArchive::extractTo() [ziparchive.extractto]: Invalid or unitialized Zip object in /home/content/38/10376438/html/viptravelink/xml/xml3.php on line 48
Warning: ZipArchive::close() [ziparchive.close]: Invalid or unitialized Zip object in /home/content/38/10376438/html/viptravelink/xml/xml3.php on line 49
Uncompression Successful
これは私が使用しているスクリプトです:
<?php
/*
* XML Sender/Client.
*/
$xmlRequest = '<?xml version="1.0" encoding="utf-8"?>
<Request> <Source><RequestorID Client="***" EMailAddress="xml@***.com" Password="***" /> <RequestorPreferences Language="en" Currency="USD"> <RequestMode>SYNCHRONOUS</RequestMode> </RequestorPreferences> </Source> <RequestDetails> <ItemInformationDownloadRequest ItemType="hotel">
<IncrementalDownloads>
</IncrementalDownloads>
</ItemInformationDownloadRequest> </RequestDetails></Request>';
// We send XML via CURL using POST with a http header of text/xml.
$url = 'https://interface.demo.gta-travel.com/rbsusapi/RequestListenerServlet';
$ch = curl_init();
$zipPath = '/home/content/38/10376438/html/viptravelink/xml/' .date('m-d-Y_h-i-s'). '.zip';
$out = fopen($zipPath, 'wb');
echo "File Opening Successful<br>";
if ($out == FALSE){
echo "Download Failed<br>";
exit;
}
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_SSLVERSION, 3); // Force SSLv3 to fix Unknown SSL Protocol error
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_FILE, $out);
curl_setopt( $ch, CURLOPT_POSTFIELDS,$xmlRequest );
curl_setopt($ch,CURLOPT_ENCODING , "gzip");
curl_setopt($ch,CURLOPT_AUTOREFERER , 1);
curl_setopt($ch,CURLOPT_MAXREDIRS , 10);
curl_setopt($ch, CURLOPT_HEADER, 1);
$result=curl_exec($ch);
$httpCode = curl_getinfo($ch);
curl_close($ch);
fclose($out);
$zip = new ZipArchive;
if (!$zip) {
echo "Could not make ZipArchive object.<br>";
exit;
}
$zip->open('$zipPath');
$zip->extractTo('/home/content/38/10376438/html/viptravelink/xml/content/');
$zip->close();
echo "Uncompression Successful<br>";
?>
どんな助けでも大歓迎です!!
ありがとうございました!