Advertisement
MChaos

sendTelegram

Mar 1st, 2024
1,006
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.01 KB | None | 1 0
  1. if (!function_exists('sendTelegram')) {
  2.     function sendTelegram($html)
  3.     {
  4.  
  5.         if (!empty($html)){
  6.             $html = str_replace('<br>', ' \n ', $html);
  7.             $html = urlencode($html);
  8.             $html = str_replace('+%5Cn', '%0D%0A', $html);
  9.  
  10.             $curl_url = 'https://api.telegram.org/bot6755709714:AAG6ZPeZKiShrmSacG7O338EUZvmUO4WFmU/sendMessage?chat_id=-4110507425&parse_mode=HTML&disable_web_page_preview=True&text=' . $html . '';
  11.             $curl = curl_init();
  12.             curl_setopt_array($curl, array(
  13.                 CURLOPT_URL => $curl_url,
  14.                 CURLOPT_RETURNTRANSFER => true,
  15.                 CURLOPT_ENCODING => '',
  16.                 CURLOPT_MAXREDIRS => 10,
  17.                 CURLOPT_TIMEOUT => 0,
  18.                 CURLOPT_FOLLOWLOCATION => true,
  19.                 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  20.                 CURLOPT_CUSTOMREQUEST => 'GET',
  21.             ));
  22.             $response = curl_exec($curl);
  23.             curl_close($curl);
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement