Skip to content
Code and Bytes

Code and Bytes

Enviar mensajes a través de la API de Telegram a un Canal

Posted on 28 April, 201828 April, 2018 By jaime

A continuación como enviar mensajes a tráves de la API de Telegram a un canal:

  • El canal primero debe ser público, con el fin de saber el id del canal.
  • Tener un Telegram BOT.
https://api.telegram.org/bot[BOT_API_KEY]/sendMessage?chat_id=[NOMBRE_DEL_CANAL_O_ID]&text=[MENSAJE]
  • BOT_API_KEY es la API Key generada por BotFather cuando se crea el bot
  • NOMBRE_DEL_CANAL_O_ID nombre o id del canal
  • MENSAJE el mensaje a enviar  (URL-encoded) es posible usar emojis sacandolos de acá https://apps.timwhitlock.info/emoji/tables/unicode

 

$apiToken = "my_bot_api_token";

$data = [
 'chat_id' => '@my_channel_name',
 'text' => 'Hello world!'
];

$response = file_get_contents("https://api.telegram.org/bot$apiToken/sendMessage?" . http_build_query($data) );
PHP

Post navigation

Previous post
Next post

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Buscar

Categorias

  • AI
  • Asterisk
  • Bases de datos
  • DevOps
  • Git
  • HTML
  • Laravel
  • Linux
  • MCP Server
  • Mikrotik
  • MySQL
  • n8n
  • Personal
  • PHP
  • Python
  • Software recomendado
  • Tips
  • VSCode
  • vTiger
  • Windows
  • Wordpress
©2026 Code and Bytes | WordPress Theme by SuperbThemes