Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 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
7 years, 1 month 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 30 Sep 2017Sorry, 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 30 Sep 2017The 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 03 Oct 20177 years, 1 month 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 03 Oct 2017https://os.mbed.com/cookbook/HTTP-Client ? Because that one does not support HTTPS.
posted by 06 Oct 2017