B
B
bulkinegra2019-03-31 07:25:20
JavaScript
bulkinegra, 2019-03-31 07:25:20

Telegram form not submitting from JavaScript?

I want to send a form to telegram directly from a js file. New to all this.

const TOKEN = token;
const CHAT_ID = id;

function sendMsg() {
 var url = 'https://api.telegram.org/bot' + TOKEN + '/sendMessage';
 var body = JSON.stringify({ 
    chat_id: CHAT_ID,
    parse_mode: 'Markdown',
    text: "Сообщение"
 });
 var xhr = new XMLHttpRequest(); 
 xhr.open('POST', url, true);
 xhr.setRequestHeader('Content-type', 'application/json; charset=utf-8'); // 
 xhr.send(body);
 }

I get net::ERR_CONNECTION_TIMED_OUT
What could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Bogachev, 2019-03-31
@sfi0zy

What could be the problem?

In Roskomnadzor.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question