Advertisement
Guest User

Untitled

a guest
Jan 5th, 2021
653
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. <?php
  2. $token = '123:aaaaa';
  3.  
  4. //req 1 param
  5. $args = ['test' => 'test'];
  6. $method = 'getMe';
  7. //curl init
  8. $curlRequestSession = curl_init();
  9. curl_setopt_array($curlRequestSession, [
  10.     CURLOPT_RETURNTRANSFER => true,
  11.     CURLOPT_POST           => true,
  12.     CURLOPT_URL            => 'https://api.telegram.org/bot' . $token . '/' . $method,
  13. ]);
  14. //send req 1
  15. curl_setopt_array($curlRequestSession, [
  16.     CURLOPT_POSTFIELDS => $args,
  17. ]);
  18. curl_exec($curlRequestSession);
  19.  
  20. //req 2 param
  21. $args = [];
  22. $method = 'getMe';
  23. //send req 2
  24. curl_setopt_array($curlRequestSession, [
  25.     CURLOPT_POSTFIELDS => $args,
  26. ]);
  27. $response = curl_exec($curlRequestSession);
  28.  
  29. //display result
  30. if ($response === false) {
  31.     echo 'Fail ';
  32.     var_dump(curl_error($curlRequestSession));
  33.     var_dump(curl_getinfo($curlRequestSession));
  34. } else {
  35.     echo 'Success ';
  36.     var_dump($response);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement