zibo-dashboard/public/userarea/get_clienti.php
2025-06-03 12:00:19 +02:00

51 lines
1.7 KiB
PHP

<?php
header('Content-Type: application/json');
// Ottieni il token da auth_proxy.php
$auth_url = 'http://localhost/auth_proxy.php'; // Assicurati che il percorso sia corretto
$ch = curl_init($auth_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Disabilita verifica SSL
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // Disabilita verifica host
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($http_code != 200) {
echo json_encode(['error' => 'Errore nell\'autenticazione', 'http_code' => $http_code, 'response' => $response]);
exit;
}
$token = trim($response); // Rimuove spazi o newline dal token
// Usa il token per richiedere la lista dei clienti
$clienti_url = 'https://93.43.5.102/limsapi/api/odata/Cliente';
$ch = curl_init($clienti_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $token,
'Accept: application/json',
'Host: iftm.it'
]);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Disabilita verifica SSL
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // Disabilita verifica host
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curl_error = curl_error($ch);
curl_close($ch);
if ($http_code != 200) {
echo json_encode(['error' => 'Errore nella richiesta dei clienti', 'http_code' => $http_code, 'curl_error' => $curl_error, 'response' => $response]);
} else {
echo $response; // Restituisce la lista completa dei clienti in JSON
}
?>