1- Adicionar o usuário “Botfather” no Telegram;
2- Enviar “/newbot” para o Botfather;
3- Escolher o nome do Bot;
4- Escolher o nome para ele ser encontrado (tem que terminar com “bot”);
5- Pegar o Token;
6- Criar um grupo no Telegram;
7- Adicionar o bot que você criou pelo nome do passo 4;
8- Acessar a URL https://api.telegram.org/bot<TOKEN>/getupdates
(IMPORTANTE: tem um ‘bot’ antes do token na URL )
extra: Aqui demorou uns 5 minutos até aparecer o ID do grupo. Se não aparecer, chame o botfather, mande um ‘bot’, depois ‘/setprivacy’, escolha o bot, marque ‘enable’ e acesse novamente a URL.
Vai aparecer algo assim:
"chat": {
"id": -1111111111,
"title": "NOME DO GRUPO",
"type": "group",
"all_members_are_administrators": true
}
9- para postar, o código básico é esse:
<?php
$token=<TOKEN>;
$grupo=<ID DO GRUPO>;
$parametros['chat_id']=$grupo;
$parametros['text']='MENSAGEM PARA SER ENVIADA';
// PARA ACEITAR TAGS HTML
$parametros['parse_mode']='html';
// PARA NÃO MOSTRAR O PREVIW DE UM LINK
$parametros['disable_web_page_preview']=true;
$options = array(
'http' => array(
'method' => 'POST',
'content' => json_encode($parametros),
'header'=> "Content-Type: application/json\r\n" .
"Accept: application/json\r\n"
)
);
$context = stream_context_create( $options );
file_get_contents('https://api.telegram.org/bot'.$token.'/sendMessage', false, $context );
🙂
32 respostas em “Enviando/recebendo mensagens pelo Telegram usando PHP”
Olá! Pelo que eu entendi esse artigo ensina a enviar mensagens apenas para um grupo do Telegram, é isso mesmo?
É possível enviar uma mensagem par alguém que tenha uma conta no Telegram, informando o nº do telefone de registro dela?
Grato.
Opa! Fala Júnior, blz?
Cara, dá pra mandar pra pessoas também, porém somente usando o CHAT ID, que é um ID da conversa e não do usuário. Então creio que não tenha como enviar uma mensagem pra alguém que não entrou antes em contato com você.
только для вас лучший разработчик, открыть джой казино сом зеркало joy casino бонусы
My brother suggested I ould possibly like this web site. Arline Conney Wieren
Way cool! Some extremely valid points! I appreciate you writing this write-up and also the rest of the site is really good. Gusta Haven Kaltman
Hurrah! At last I got a web site from where I can in fact get helpful data regarding my study and knowledge. Farrah Nahum Ariane
I am so grateful for your article. Thanks Again. Keep writing. Aundrea Sonnie Eric
There is obviously a lot to realize about this. I feel you made various nice points in features also. Anna-Diana Osbourn Rosinski
Its not my first time to go to see this site, i am visiting this site dailly and take nice data from here daily. Lia Marsh Bandler
Way cool! Some extremely valid points! I appreciate you writing this write-up plus the rest of the site is also very good. Mureil Lockwood Brodie
Each page is sapid or funny. I invite you to new page. Elianora Yardley Jaynell
Uniqueness and Relevance Of Your App Idea: For making an out of the case application, it is crucial that your idea should bewilder and inventive. Sheelah Brenden Goldwin
Hi, I do believe yoir web site might be having internet browser compatibility problems. Kandace Chick Lois
Check beneath, are some absolutely unrelated web sites to ours, nevertheless, they may be most trustworthy sources that we use. Eveleen Leroy Whitten
I like it when folks get together and share thoughts. Great website, keep it up. Constantine Jere Wallas
Hello. This article was extremely remarkable, especially since I was looking for thoughts on this issue last Friday. Kathleen Gale Woolley
I am truly happy to glance at this webpage posts which includes plenty of helpful facts, thanks for providing these kinds of data. Tanhya Billy Limemann
Wow because this is really good work! Congrats and keep it up. Katheryn Al Westbrooke
Hurrah! At last I got a weblog from where I know how to truly get helpful facts regarding my study and knowledge. Emmi Oliviero Grane
Checked out the shark tank blurb about skincare cream. Caprice Wood Montfort
Major thanks for the article. Really looking forward to read more. Much obliged. Leah Kingston Anissa
This post is really a nice one it assists new web visitors, who are wishing for blogging. Janeta Gaylord Desmund
There is noticeably a bundle to understand about this. I think you ensured wonderful points in attributes likewise. Darcee Benji Beetner
I consider something really special in this internet site. Batsheva Sebastiano Lexi
Please go to the web sites we comply with, such as this one particular, as it represents our picks through the web. Jeanette Chaim Ita
Im grateful for the article. Really looking forward to read more. Keep writing. Pam Boyce Beltran
This website has lots of really useful stuff on it. Thanks for informing me. Nikoletta Garth Wallie
You made some nice points there. I looked on the internet for the subject matter and found most individuals will agree with your site.
Hello! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be book-marking and checking back frequently!
Hello! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be book-marking and checking back frequently!
Hello! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be book-marking and checking back frequently!
Good article. I will be experiencing a few of these issues as well.. Isidora Burty Torrence