Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $token = '123:aaaaa';
- //req 1 param
- $args = ['test' => 'test'];
- $method = 'getMe';
- //curl init
- $curlRequestSession = curl_init();
- curl_setopt_array($curlRequestSession, [
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_POST => true,
- CURLOPT_URL => 'https://api.telegram.org/bot' . $token . '/' . $method,
- ]);
- //send req 1
- curl_setopt_array($curlRequestSession, [
- CURLOPT_POSTFIELDS => $args,
- ]);
- curl_exec($curlRequestSession);
- //req 2 param
- $args = [];
- $method = 'getMe';
- //send req 2
- curl_setopt_array($curlRequestSession, [
- CURLOPT_POSTFIELDS => $args,
- ]);
- $response = curl_exec($curlRequestSession);
- //display result
- if ($response === false) {
- echo 'Fail ';
- var_dump(curl_error($curlRequestSession));
- var_dump(curl_getinfo($curlRequestSession));
- } else {
- echo 'Success ';
- var_dump($response);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement