Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.13 KB | None | 0 0
  1. <?PHP
  2.     date_default_timezone_set('UTC');
  3.    
  4.     $arrContextOptions=array(
  5.         "ssl"=>array(
  6.             "verify_peer"=>false,
  7.             "verify_peer_name"=>false,
  8.         ),
  9.     );
  10.    
  11.     $token = "1070521047:AAEJMemE63Em-3ULbXGta7Rulq6Z8iUluWM";
  12.  
  13.     $telegram = [
  14.         'text' => 'wayToTwoCrown',
  15.         'chat_id' => '954384299'
  16.     ];
  17.    
  18.     $doOnce = true;
  19.    
  20.     $url = 'https://time.aacargo.info/api/v2/';
  21.     $file = file_get_contents($url, false, stream_context_create($arrContextOptions));
  22.     $data = json_decode($file, true);
  23.    
  24.     $time = array();
  25.  
  26.     for ($i = 0; $i < 14; $i = $i + 1) {
  27.         $status = $data['na'][$i]['status'];
  28.        
  29.         if ($status == "wayToTwoCrown") {
  30.             $time[$i / 4] = $data['na'][$i]['time'];
  31.         }
  32.     }
  33.    
  34.     $currentTime = date('d.m.Y H:i:s', time());
  35.     $difference = (strtotime($time[0]) - strtotime($currentTime)) / 60;
  36.    
  37.     echo "Current time: " . $currentTime . "</br>";
  38.     echo $difference . " minutes left for wayToTwoCrown";
  39.    
  40.     if ((strtotime($time[0]) - strtotime($currentTime)) / 60 <= 8.0) {
  41.         if ($doOnce) {
  42.             file_get_contents('https://api.telegram.org/bot' . $token . '/sendMessage?' . http_build_query($telegram));
  43.             $doOnce = false;
  44.         }
  45.     }
  46. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement