adding more Info about Company
This commit is contained in:
parent
b5c26c48bf
commit
1ea18c23f8
|
@ -4,10 +4,10 @@ include "read_write_xlsx.php";
|
|||
|
||||
include "emailSender.php";
|
||||
|
||||
$maxExecutionTime = 300;
|
||||
$maxExecutionTime = 62;
|
||||
$taskDir = 'tasks';
|
||||
$downloadDir = 'download';
|
||||
$minTaskOldness = 30;
|
||||
$minTaskOldness = 5;
|
||||
$latesEndTime = time() + $maxExecutionTime;
|
||||
$smtppassword = getenv("smtppassword");
|
||||
|
||||
|
@ -21,13 +21,14 @@ function doRequest($data, $filename, $username, $password)
|
|||
$companyArray = json_decode($response, true);
|
||||
$companyData = array();
|
||||
foreach ($companyArray as $company) {
|
||||
$companyData[] = [$company['name'],$company['ehraid'],$company['uid'],$company['chid'],$company['legalSeat'],$company['registryOfCommerceId'],$company['legalForm']['name']['de'],$company['status'],$company['sogcDate'],$company['deletionDate']];
|
||||
$companyFullData = json_decode(sendAPICompanyInfoRequest($username, $password, $company['uid']), true)[0];
|
||||
$companyData[] = [$companyFullData['name'],$companyFullData['address']['street'], $companyFullData['address']['houseNumber'], $companyFullData['address']['swissZipCode'], $companyFullData['address']['city'],$companyFullData['uid'],$companyFullData['legalSeat'],$companyFullData['legalForm']['name']['de'],$companyFullData['status'],$companyFullData['sogcDate'],$companyFullData['deletionDate']];
|
||||
}
|
||||
if (! file_exists($filename)) {
|
||||
// If File doesn't exist yet
|
||||
$file = fopen($filename, 'w');
|
||||
if($file) {
|
||||
fputcsv($file, ['name', 'ehraid', 'uid', 'chid', 'legalSeat', 'registryOfCommerceId', 'legalForm', 'status', 'sogcDate', 'deletionDate']);
|
||||
fputcsv($file, ['name', 'street', 'houseNumber', 'swissZipCode', 'city', 'uid', 'legalSeat', 'legalForm', 'status', 'sogcDate', 'deletionDate']);
|
||||
}
|
||||
} else {
|
||||
// If file already exists
|
||||
|
|
31
zefixAPI.php
31
zefixAPI.php
|
@ -3,6 +3,37 @@ include 'env_vars.php';
|
|||
$username = getenv("username");
|
||||
$password = getenv("password");
|
||||
|
||||
function sendAPICompanyInfoRequest(string $username, string $password, string $uid): string|bool {
|
||||
|
||||
// API endpoint
|
||||
$apiUrl = 'https://www.zefix.admin.ch/ZefixPublicREST/api/v1/company/uid/'.$uid;
|
||||
|
||||
// Headers
|
||||
$headers = array(
|
||||
"accept: application/json",
|
||||
"Content-Type: application/json"
|
||||
);
|
||||
|
||||
// Initialize cURL session
|
||||
$ch = curl_init();
|
||||
// Set cURL options
|
||||
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
|
||||
curl_setopt($ch, CURLOPT_URL, $apiUrl);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, false);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Disable SSL verification
|
||||
|
||||
// Execute cURL session and get the response
|
||||
$response = curl_exec($ch);
|
||||
// Check for cURL errors
|
||||
if (curl_errno($ch)) {
|
||||
echo 'Curl error: ' . curl_error($ch);
|
||||
}
|
||||
// Close cURL session
|
||||
curl_close($ch);
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $
|
||||
|
|
Loading…
Reference in New Issue