diff --git a/shalom_api.php b/shalom_api.php index e1c6170..bead474 100644 --- a/shalom_api.php +++ b/shalom_api.php @@ -13,14 +13,23 @@ if (!$orderNumber || !$orderCode) { // 2. Configurar la llamada a la API de Shalom $apiKey = 'sk_mlq1j3na_4a676ewvaop'; -// La URL del endpoint de tracking según la documentación inferida. -$url = "https://shalom-api.lat/api/tracking/$orderNumber/$orderCode"; +$url = "https://shalom-api.lat/api/track"; // Endpoint correcto para POST + +// Datos para el cuerpo de la solicitud POST +$postData = [ + 'orderNumber' => $orderNumber, + 'orderCode' => $orderCode +]; +$jsonData = json_encode($postData); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +curl_setopt($ch, CURLOPT_POST, true); // Especificar que es una solicitud POST +curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData); // Enviar los datos en formato JSON curl_setopt($ch, CURLOPT_HTTPHEADER, [ + 'Content-Type: application/json', 'Accept: application/json', "Authorization: Bearer {$apiKey}" ]); diff --git a/test_pedidos.php b/test_pedidos.php index 4907ade..04c6dc7 100644 --- a/test_pedidos.php +++ b/test_pedidos.php @@ -195,7 +195,58 @@ include 'layout_header.php';
Error: ${data.error}
`; + } else if (data.search && data.search.success) { + const searchData = data.search.data; + const statusData = data.statuses.data; + const statusMessage = data.statuses.message || 'No disponible'; + + let html = ` +${searchData.origen.nombre}
+${searchData.origen.direccion}
+${searchData.destino.nombre}
+${searchData.destino.direccion}
+${item.name}: ${new Date(item.data.fecha).toLocaleString('es-PE', { timeZone: 'America/Lima' })}
`; + } else { + html += `${item.name}: Pendiente
`; + } + }); + + html += ` +${JSON.stringify(data, null, 2)}`;
+ modalStatusDiv.innerHTML = `No se pudo encontrar la guía o la respuesta no es válida.
${JSON.stringify(data, null, 2)}`;
}
})
.catch(error => {