3 years, 1 month ago.

Telegram Bot Problem with Post HTTP

I have tried to send a message to a telegram bot with HTTPClient. But, it was not successful. When I simply copy the link in the browser I receive the text but I cannot when I use mbed. I'd be grateful if you could help me!

char telegram[]= "https://api.telegram.org/bot(Bot Token)/sendMessage?chat_id=(Chat ID)&text=(text)"; HTTPMap map; HTTPText text(str, 1); map.put("", "");

http.post(telegram, map, &text,1);

2 Answers

3 years ago.

Hi Reza,

The telegram references an https-secured site. Are you using a version of the HTTPClient that support secure transactions?

Hi David, Thank you for your response. The HTTPClient I use can post to "https://api.thingspeak.com/update?api_key=". But, I didn't know that there are several libraries for http Client. May I know which library you use for telegram bot? Thank you

posted by Reza Mashayekhi 30 Sep 2017

Sorry, I didn't mean to lead you into thinking I had a working solution. I have not yet implemented any secure client (and I don't use the telegram bot). But as I looked at your code, I saw the https. The common HTTPClient packages you might find on the mbed site cannot do secure transactions.

posted by David Smart 30 Sep 2017

The library can work with ThingSpeak website which is also https so that the library can handle the secure client. However, I tend to think the library has a problem regarding the length of URL. I think the way library shrink the URL cannot handle telegram API. I hope it could handle it...

posted by Reza Mashayekhi 03 Oct 2017
3 years ago.

HTTPClient cannot do HTTPS, which is what you're trying to use. http-example can do HTTPS, but it does not run on LPC1768 because it has too little RAM for the TLS handshake.

Dear Jan Thank you for your response. It can work with ThingSpeak API which is also HTTPS. May I ask you how I can send a text to a telegram bot with LPC1768? Thanks

posted by Reza Mashayekhi 03 Oct 2017

Which library are you using?

posted by Jan Jongboom 03 Oct 2017


posted by Reza Mashayekhi 05 Oct 2017

https://os.mbed.com/cookbook/HTTP-Client ? Because that one does not support HTTPS.

posted by Jan Jongboom 06 Oct 2017

Are there any other libraries which support https?

posted by Reza Mashayekhi 06 Oct 2017

mbed-http supports it, but as noted on the project page, the TLS handshake consumes too much memory. Unless you can fix that it's not possible on the LPC1768.

posted by Jan Jongboom 06 Oct 2017