Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@isholgueras
Last active December 22, 2022 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isholgueras/d9d9d599416d84e86b880e3774b81946 to your computer and use it in GitHub Desktop.
Save isholgueras/d9d9d599416d84e86b880e3774b81946 to your computer and use it in GitHub Desktop.
Script en PHP para comprobar los números de la lotería de navidad utilizando la api de elpais.com
<html>
<body>
<?php
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$request_url = "https://api.elpais.com/ws/LoteriaNavidadPremiados?n=";
$numbers = [
12345,
67890,
];
?>
<h1>Resultados</h1>
<ul>
<?php foreach ($numbers as $number) {
$result = json_decode(str_replace("busqueda=", '', file_get_contents($request_url . $number)));
$premio = $result->premio . " EEEEEUUROOOOOOS!!!!!!!!";
if ($result->premio === 0) {
$premio = "Un mojón pa tí.";
}
?>
<li><strong><?= $result->numero?></strong>: <?= $premio ?></li>
<?php } ?>
</ul>
<strong>Última actualización: </strong> <?= date('m/d/Y H:i:s', $result->timestamp + 3600)?>
</body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment