fbpx
ISTOTEXNIKI
WEB SOLUTIONS
Δημιουργία xml αρχείου με τη μέθοδο POST

Create xml file with POST method

XML file with the POST method

Generating xml file with POST method it is often necessary when the company that supplies it to us has it locked for security reasons. With the POST method and if we have the email and the code required, we can generate an xml file from the link that will be given to us.

We create a new file with the extension php in its home directory our server. This is usually the folder (public_html for context-based systems cPanel and CyberPanel – httpdocs for Plesk based systems).

There we simply copy the code below where we replace the demo url ("to-url-sas") with the real url given to us by our partner and fill in the email (to-email-sas) & code (o-kodikos -sas) required for authentication. We save and run the file, so the file is created automatically arxeio.xml in the same place as the php file we created.

You can use a cron job to run at intervals (as often as you want) so that you always have the latest version of your file.

open($zip_file) != "true") { echo "Error :- Unable to open the Zip File"; } $zip->extractTo($extrPath); $zip->close(); } function postRequest() { $url = "to-url-sas"; $zip_file = "arxeio.xml"; $zip_resource = fopen($zip_file, "w"); $ch_start = curl_init(); curl_setopt($ch_start, CURLOPT_URL, $url); curl_setopt($ch_start, CURLOPT_POST, 1); curl_setopt($ch_start, CURLOPT_POSTFIELDS,"email=to-email-sas&password=o-kodikos-sas"); curl_setopt($ch_start, CURLOPT_FAILONERROR, true); curl_setopt($ch_start, CURLOPT_HEADER, 0); curl_setopt($ch_start, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch_start, CURLOPT_AUTOREFERER, true); curl_setopt($ch_start, CURLOPT_BINARYTRANSFER,true); curl_setopt($ch_start, CURLOPT_TIMEOUT, 100); curl_setopt($ch_start, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch_start, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch_start, CURLOPT_FILE, $zip_resource); $page = curl_exec($ch_start); print_r($page); if(!$page) { echo "Error :- ".curl_error($ch_start); } curl_close($ch_start); /* $zip = new ZipArchive; $extractPath = "PostDownloadFolder"; if($zip->open($zip_file) != "true") { echo "Error :- Unable to open the Zip File"; } $zip->extractTo($extrPath); $zip->close();*/ } postRequest(); ?>
ΚΛΕΙΣΙΜΟ