Last active
December 5, 2024 10:56
-
-
Save maduranma/685e0974d2ded63c5bc66473079f6433 to your computer and use it in GitHub Desktop.
Spanish Christmas Lottery "Lotería de Navidad 2022" - PHP auto-checker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Spanish Christmas Lottery 2022 auto-checker in PHP | |
-------------------------------------------------- | |
Fill your coupons below, 20€ is one ticket, insert the quantity you play of each number in euros | |
Example: 20€ is one ticket, 10€ half a ticket (if you play with someone) or 40€ two tickets. | |
You can also repeat the same number for two different persons. | |
It updates once every minute. | |
Good luck! | |
Author: Martín Durán <[email protected]> | |
*/ | |
$coupons = [ | |
['number' => '11111', 'quantity' => 20, 'person' => 'YOUR NAME'], | |
['number' => '22222', 'quantity' => 20, 'person' => 'YOUR NAME'], | |
// Add as many entries as you want | |
]; | |
function out($prestring, $poststring) { | |
echo str_pad($prestring, 15, ' '), $poststring; | |
} | |
while(true) | |
{ | |
$cache = []; | |
foreach($coupons as $coupon) | |
{ | |
if(!isset($cache[$coupon['number']])) | |
sleep(1); | |
$response = $cache[$coupon['number']] ??= json_decode(explode('=', file_get_contents('https://api.elpais.com/ws/LoteriaNavidadPremiados?n=' . $coupon['number']), 2)[1], true); | |
if($response['premio'] > 0) | |
{ | |
echo out($coupon['person'] . ':', '[' . $coupon['number'] . ' - ' . $coupon['quantity'] . 'EUR] DING DING DING -> EL PREMIO SON: ' . number_format($response['premio'] / 20 * $coupon['quantity'], 0, '', '.') . ' EUROS!!!'); | |
} | |
else | |
{ | |
echo out($coupon['person'] . ':', '[' . $coupon['number'] . ' - ' . $coupon['quantity'] . 'EUR] No tiene premio (de momento), sigue esperando...'); | |
} | |
echo PHP_EOL; | |
} | |
echo '-------------------------------------------', PHP_EOL; | |
sleep(60); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment