89 lines
2.3 KiB
PHP
89 lines
2.3 KiB
PHP
<?php
|
|
require_once dirname(__DIR__, 2) . '/vendor/autoload.php';
|
|
require_once dirname(__FILE__) . '/class/VisualLimsApiClient.class.php';
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
ini_set('display_errors', '0');
|
|
error_reporting(E_ALL);
|
|
|
|
try {
|
|
$api = VisualLimsApiClient::getInstance();
|
|
|
|
// Campione hardcoded del tuo esempio
|
|
$idCampione = 749027;
|
|
|
|
// Matrice attesa dal log STEP 6
|
|
$expectedMatriceId = 6430;
|
|
|
|
// Endpoint con expand della Matrice
|
|
$endpoint = "Campione($idCampione)";
|
|
$options = [
|
|
'$expand' => 'Matrice'
|
|
];
|
|
|
|
// Debug URL
|
|
$base_url = 'https://93.43.5.102/limsapi/api/odata/';
|
|
$query = http_build_query($options);
|
|
$queryReadable = urldecode($query);
|
|
|
|
$full_url = $base_url . $endpoint . ($queryReadable ? '?' . $queryReadable : '');
|
|
|
|
file_put_contents(
|
|
__DIR__ . '/last_url_check_matrice.txt',
|
|
$full_url . PHP_EOL,
|
|
FILE_APPEND
|
|
);
|
|
|
|
// Chiamata API
|
|
$data = $api->get($endpoint, $options);
|
|
|
|
// Recupero Matrice dalla response
|
|
$matrice = $data['Matrice'] ?? null;
|
|
|
|
$actualMatriceId = null;
|
|
|
|
if (is_array($matrice)) {
|
|
// Provo i nomi più probabili
|
|
$actualMatriceId = $matrice['IdMatrice']
|
|
?? $matrice['idMatrice']
|
|
?? $matrice['Id']
|
|
?? $matrice['ID']
|
|
?? null;
|
|
}
|
|
|
|
$matrice_ok = ((int)$actualMatriceId === (int)$expectedMatriceId);
|
|
|
|
$output = [
|
|
'success' => true,
|
|
'idCampione' => $idCampione,
|
|
'expectedMatriceId' => $expectedMatriceId,
|
|
'actualMatriceId' => $actualMatriceId,
|
|
'matrice_ok' => $matrice_ok,
|
|
'request_url' => $full_url,
|
|
'matrice' => $matrice,
|
|
'raw_response' => $data
|
|
];
|
|
|
|
// Salva JSON completo
|
|
file_put_contents(
|
|
__DIR__ . '/check_matrice_campione_749027_response.json',
|
|
json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)
|
|
);
|
|
|
|
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|
|
} catch (Exception $e) {
|
|
file_put_contents(
|
|
__DIR__ . '/error_log_check_matrice.txt',
|
|
date('Y-m-d H:i:s') . ' - ' . $e->getMessage() . PHP_EOL,
|
|
FILE_APPEND
|
|
);
|
|
|
|
http_response_code(500);
|
|
|
|
echo json_encode([
|
|
'success' => false,
|
|
'error' => $e->getMessage()
|
|
], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|
|
}
|