Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

760
Visualizações
Enviar mensaje a Telegram a través de formulario html usando Javascript

¿Es posible enviar datos de formulario a Telegram usando Javascript? Leí muchas respuestas, pero casi todas están basadas en php.

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Sí, puede programar su bot de Telegram y enviar cualquier mensaje usando javascript (usando AJAX ya que la API del bot de Telegram es una API basada en solicitudes web).

Por ejemplo, envía un mensaje a un usuario específico con esto:

 let tg = { token: "BOT_TOKEN", // Your bot's token that got from @BotFather chat_id: "CHAT_ID" // The user's(that you want to send a message) telegram chat id } /** * By calling this function you can send message to a specific user() * @param {String} the text to send * */ function sendMessage(text) { const url = `https://api.telegram.org/bot${tg.token}/sendMessage?chat_id=${tg.chat_id}&text=${text}`; // The url to request const xht = new XMLHttpRequest(); xht.open("GET", url); xht.send(); } // Now you can send any text(even a form data) by calling sendMessage function. // For example if you want to send the 'hello', you can call that function like this: sendMessage("hello");

También puede usar la solicitud POST para enviar datos. Por ejemplo:

 let tg = { token: "BOT_TOKEN", // Your bot's token that got from @BotFather chat_id: "CHAT_ID" // The user's(that you want to send a message) telegram chat id } /** * By calling this function you can send message to a specific user() * @param {String} the text to send * */ function sendMessage(text) { const url = `https://api.telegram.org/bot${tg.token}/sendMessage` // The url to request const obj = { chat_id: tg.chat_id, // Telegram chat id text: text // The text to send }; const xht = new XMLHttpRequest(); xht.open("POST", url, true); xht.setRequestHeader("Content-type", "application/json; charset=UTF-8"); xht.send(JSON.stringify(obj)); } // Now you can send any text(even a form data) by calling sendMessage function. // For example if you want to send the 'hello', you can call that function like this: sendMessage("hello");

Para obtener más información, consulte la documentación de la API del bot de Telegram: https://core.telegram.org/bots/api

Perdón por mi mal ingles. De todos modos, espero que esto ayude :)

about 4 years ago · Santiago Trujillo Relatório

0

Puede utilizar la API de Telegram para enviar mensajes.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda