Sending a message to the telegram channel
Rus
Eng
Отправка сообщения в канал телеграмма

All English-language materials have been translated fully automatically using the Google service

Get the bot token

Find a special contact in the telegram @botfarther

Sending a command to create a bot /newbot

Enter a unique name for the bot, get and save the bot token

Getting the channel id in telegrams

1. Create a channel
2. We write any message to the channel
3. Find contact @getmyid_bot
4. We forward him any message from our channel
5. Get and save the id of the user, the current chat and the desired chat. Save the value from "Forwarded from chat". Using 

Sending a message to the telegram channel

function send(text){
	// Токен бота и идентификатор чата
	$token='';
	$chat_id='';

	// Отправить сообщение
	$ch=curl_init();
	curl_setopt($ch, CURLOPT_URL,'https://api.telegram.org/bot'.$token.'/sendMessage');
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_HEADER, false);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($ch, CURLOPT_POST, true);
	curl_setopt($ch, CURLOPT_POSTFIELDS,'chat_id='.$chat_id.'&text='.urlencode($text));
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);

	// Настройки прокси, если это необходимо
	/*
	curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
	curl_setopt($ch, CURLOPT_PROXY, $proxy);
	curl_setopt($ch, CURLOPT_PROXYUSERPWD, $auth);
	*/

	// Отправить сообщение
	$result=curl_exec($ch);
	curl_close($ch);
}

Comments

There are no comments yet, you can be the first to leave it

Leave a comment

The site uses a comment pre-moderation system, so your message will be published only after approval by the moderator

You are replying to a user's comment

Send

FEEDBACK

Email me

Are you developing a new service, making improvements to the existing one and want to be better than your competitors? You have come to the right place. I offer you a comprehensive studio-level website development. From me you can order design, layout, programming, development of non-traditional functionality, implementation of communication between CMS, CRM and Data Analitics, as well as everything else related to sites, except for promotion.

Contact, I will always advise on all questions and help you find the most effective solution for your business. I am engaged in the creation of sites in Novosibirsk and in other regions of Russia, I also work with the CIS countries. You will be satisfied with our cooperation

An error occurred while sending, please try again after a while
Message sent successfully

Phones

+7(993) 007-18-96

Email

info@tichiy.ru

Address

Россия, г. Москва

By submitting the form, you automatically confirm that you have read and accept the Privacy Policy site

Contact with me
Send message
By submitting the form, you automatically confirm that you have read and accept Privacy policy of site
Sending successful!
Thank you for contacting :) I will contact you as soon as possible
Sending failed
An error occurred while sending the request. Please wait and try again after a while or call my phone number