RuslanK

chatBot

May 28th, 2021 (edited)
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. <?php
  2.     $token = '777';
  3.    
  4.     $ch = 'https://api.telegram.org/bot' . $token; 
  5.     $ch = curl_init($ch . '/getUpdates');  
  6.     $ch = setOpt($ch, $response);
  7.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  8.     $sendMessage = curl_exec($ch);
  9.     curl_close($ch);    
  10.    
  11.     ob_start();
  12.     print_r($sendMessage);
  13.     $out = ob_get_clean();
  14.     file_put_contents(__DIR__ . '/message.txt', $out);  
  15.    
  16.     function setOpt($ch, $response)
  17.     {
  18.         curl_setopt($ch, CURLOPT_POST, 1);  
  19.         curl_setopt($ch, CURLOPT_HEADER, false);       
  20.        
  21.         return $ch;
  22.     }  
  23. ?>
  24.  
Add Comment
Please, Sign In to add comment