'https://clientes.elit.com.ar/v1/api/productos?'.$searchTerm.'limit='.$perPage.'&offset='.$offset,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{"user_id":251,"token":"xoaefq9nmso"}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
// Decodificar la respuesta JSON
$json = json_decode($response, true);
// Verificar si hay errores en la respuesta
if (isset($json['error'])) {
echo 'Error al obtener productos: ' . $json['error'];
} else {
// Obtener los productos de la respuesta
$products = isset($json['resultado']) ? $json['resultado'] : [];
// Iterar sobre los productos y generar el HTML correspondiente
foreach ($products as $product) {
echo '
';
foreach ($product["imagenes"] as $image) {
echo '
';
}
echo '
' . $product["nombre"] . '
';
echo '
Precio: $' . $product["pvp_ars"] . '
';
echo '
Consultar por WhatsApp';
echo '
';
}
}
?>