jb-data.de/ilo_csv.php
2025-08-11 22:23:30 +02:00

59 lines
No EOL
1.8 KiB
PHP

<?php
// error_reporting(E_ALL); ini_set('display_errors',1);
$kw_aktuell = (int)date('W');
$jahr = (int)date('Y');
require('lib/config.php');
require('lib/mysql.class.php');
$GLOBALS['mysql'] = new mysql(CONFIG_MYSQL_HOST,CONFIG_MYSQL_USER,CONFIG_MYSQL_PW,CONFIG_MYSQL_DB);
mysqli_set_charset($mysql, 'utf8');
header("Content-Type: text/html; charset=utf-8");
//----------------------------------------------------------------------------------------------------------------
//$url='https://api.ilonexs.de/php/schnittstellen_url.php?api=MbL~9X2kZU~&schnittstelle=1&';
$url='https://api.ilonexs.de/php/schnittstellen_url.php?api=MbL~9X2kZU~&schnittstelle=1/schnittstellen_url.php';
//----------------------------------------------------------------------------------------------------------------
$saveTo = 'ilo1.csv';
$fp = fopen($saveTo, 'w+');
//If $fp is FALSE, something went wrong.
if($fp === false){
throw new Exception('Could not open: ' . $saveTo);
}
//Create a cURL handle.
$ch = curl_init($url);
//Pass our file handle to cURL.
curl_setopt($ch, CURLOPT_FILE, $fp);
//Timeout if the file doesn't download after 20 seconds.
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
//Execute the request.
curl_exec($ch);
//If there was an error, throw an Exception
if(curl_errno($ch)){
throw new Exception(curl_error($ch));
}
//Get the HTTP status code.
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
//Close the cURL handler.
curl_close($ch);
//Close the file handler.
fclose($fp);
if($statusCode == 200){
echo 'Downloaded!';
} else{
echo "Status Code: " . $statusCode;
}
//----------------------------------------------------------------------------------------------------------------
echo "<pre>"; print_r($data); echo "</pre>";
echo "<pre>"; print_r($output); echo "</pre>";
?>