Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sendMessage($to, $message){
- $url = "https://api.telegram.org/bot" . $bot_token . "/sendMessage";
- $postData = [
- 'chat_id' => $to,
- // 'parse_mode' => 'HTML',
- 'text' => $message
- ];
- $header = [
- "X-Requested-With: XMLHttpRequest",
- "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36"
- ];
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- $response = curl_exec($ch);
- $err = curl_error($ch);
- curl_close($ch);
- if($err){
- $response = $err;
- }
- return json_decode($response, true);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement