• ADS
 • CSS
 • EXCEL
 • IMAGE-SERVER
 • SCRIPTS
 • SEO
 • WEB-PAGE-LANGUAGES
 • WEB-SERVER
 • WEBSITE-MONITORING-AND-BACKUP
SCRIPTS | 
PHP-SCRIPTS | 
TELEGRAM-API-SENDMESSAGE
How to Send Message using Telegram API in your PHP Website
Full set of Telegram API manual page: https://core.telegram.org/bots/api
SEND MESSAGE TO TELEGRAM CHANNEL USING PHP API
1) 
You have to create your own bot. For this go to 
https://t.me/botfather (or Open Telegram & Search "BotFather". There may be multiple bot with same name, but go to that one, which is telegram verified. Others are fake)
2) Send message "
/newbot" for creation of your new bot. Enter a name of your bot. (E.g. jsarkar)
3) Now you've to choose a username of your newly created bot. 
It must end in 'bot'. (E.g. jsarkarbot)
4) After adding an username to your bot, BotFather gives you a token with which you can use Telegram's HTTP API. Note this API token. It is like "
1234567890:ABCDefghIJKlmnoPqrsT-abc123efg". We call this as <API_Token>. *
5) Now create any group and 
add your newly created bot with this group and promote to Admin. **
6) Now run the following url to browser and you get chat_id. 
https://api.telegram.org/bot<API_Token>/getUpdates e.g. 
https://api.telegram.org/bot1234567890:ABCDefghIJKlmnoPqrsT-abc123efg/getUpdates (This is demo url. Always use your own token)
7) When you run the above url to browser, you get a following line:
   "chat":{"id":-503629931,"title":"Your Work","type":"group","all_members_are_administrators":true}. Note down chat_id. ***
    
* You can get this token any time later from BotFather. Send message "
/mybots" & you get your bots. Click them & you find token again.
** You can add your bot to a channel also.
*** If you add your bot to a channel, then chat_id is @<channel_permanent_link>. E.g. if then channel link is 
https://t.me/recharge_offers, then chat_id is 
@recharge_offers
Now we have send message to a channel / group using Telegram API.
API URL: https://api.telegram.org/bot<API_Token>/sendMessage?
Parameters:
i) chat_id: To which group/channel, chat is sent.
ii) text: Text to sent.
iii) disable_web_page_preview: True / False
To see all parameters, click here 
https://core.telegram.org/bots/api#sendmessage
PHP Code:
<?
  $botToken="1234567890:ABCDefghIJKlmnoPqrsT-abc123efg"; // always your your token
  $website="https://api.telegram.org/bot".$botToken;
  $params=[
      'chat_id'=>'@recharge_offers', 
      'text'=>'Hello Sir',
      'disable_web_page_preview'=>False,
      'can_add_web_page_previews'=>True
  ];
  $ch = curl_init($website . '/sendMessage');
  curl_setopt($ch, CURLOPT_HEADER, false);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, ($params));
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  $result = curl_exec($ch);
  curl_close($ch);
?>>