66 lines
1.3 KiB
PHP
66 lines
1.3 KiB
PHP
|
|
<?php
|
|
//include 'env_vars.php';
|
|
$username = getenv("username");
|
|
$password = getenv("password");
|
|
|
|
|
|
// API endpoint
|
|
$apiUrl = 'https://www.zefix.admin.ch/ZefixPublicREST/apicompany/search';
|
|
|
|
// Request data
|
|
$data = array(
|
|
"name" => "Silias KLG",
|
|
"legalFormId" => 4,
|
|
"legalFormUid" => "0107",
|
|
"registryOfCommerceId" => 36,
|
|
"legalSeatId" => 623,
|
|
"canton" => "BE",
|
|
"activeOnly" => true
|
|
);
|
|
|
|
// Headers
|
|
$headers = array(
|
|
"username:".$username,
|
|
"password:".$password
|
|
);
|
|
phpinfo();
|
|
// Initialize cURL session
|
|
$ch = curl_init();
|
|
|
|
// Set cURL options
|
|
curl_setopt($ch, CURLOPT_URL, $apiUrl);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_POST, true);
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
|
|
|
// 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);
|
|
|
|
// Output the API response
|
|
echo $response;
|
|
|
|
|
|
|
|
// Close cURL
|
|
curl_close($ch);
|
|
|
|
// Process the Zefix response and construct your own response
|
|
// ...
|
|
$constructed_response = $response;
|
|
|
|
// Send the response back to the client
|
|
header('Content-Type: application/json');
|
|
echo $constructed_response;
|
|
|
|
|
|
?>
|