As the title says... Chat on...

User avatar
By Elyoni
#25187 Hello,

I am trying to build a Telegram Bot with the new API, but i have a problem with send the request.

When i try to send a request comment with the NodeMCU i don't get nothing
My Code is:
Code: Select allHOST = 'api.telegram.org'

conn=net.createConnection(net.TCP, 0)
conn:on("receive", function(conn, payload) print(payload) end )
conn:connect("443",HOST)
conn:send("GET / HTTP/1.1\r\nHost: https://api.telegram.org/bot<My_Token_Code>/getUpdates \r\n"
.."Connection: keep-alive\r\nAccept: */*\r\n\r\n")


After it run i Get:
Code: Select allHTTP/1.1 400 Bad Request
Server: nginx/1.6.2
Date: Thu, 06 Aug 2015 14:00:05 GMT
Content-Type: text/html
Content-Length: 172
Connection: close

<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx/1.6.2</center>
</body>
</html>


Hope that you can tell me what i am doing wrong
User avatar
By Giancarlo
#26971 Hi, are you still interested in developing telegram bot for esp8266?
The reason why your code does not work is that Telegram.org requires https (http secure) and at the moment the esp8266 does not provide that kind of service.
but, still there is an alternative solution...
If you want a telegram bot library written for esp8266 under Arduino Ide, have a look to my github repository. I'm interested to have your feedback.
Giancarlo
User avatar
By Lstt
#30365
Giancarlo wrote:Hi, are you still interested in developing telegram bot for esp8266?
The reason why your code does not work is that Telegram.org requires https (http secure) and at the moment the esp8266 does not provide that kind of service.
but, still there is an alternative solution...
If you want a telegram bot library written for esp8266 under Arduino Ide, have a look to my github repository. I'm interested to have your feedback.
Giancarlo

Dear friend! I try today you library with changes for ESP8266 Arduino IDE - https://github.com/Lstt2005/ESP8266_I.O ... choBot.ino , but has erros:
Code: Select all................
WiFi connected
IP address:
192.168.0.79
GET Update Messages

Soft WDT reset

ctx: cont
sp: 3ffebc20 end: 3ffec150 offset: 01b0

            stack>>>
            3ffebdd0: 0002e5cd 00000000 00000000 4022c567
            3ffebde0: 3fffbba8 3fff5668 3fff57d0 4022c700
            3ffebdf0: 00000000 ffffffff 3fffbb88 3fff5668
            3ffebe00: 00000040 3fff5668 3fffa2e8 4022cafd
            3ffebe10: 3fff6890 3fff5668 3fffa2e8 4022d504
            3ffebe20: 3fff5730 53134450 0a75423b 00000001
            3ffebe30: 3fff5668 3fffa2c8 3fffa2e8 00000001
            3ffebe40: 00000010 3fff5668 0000000f 4022d775
            3ffebe50: 3fff57d0 3fff5770 0000000f 00000001
            3ffebe60: 00000001 3fff57b0 00000000 4022c5cc
            3ffebe70: 00000100 3fff7343 3fff7343 00000000
            3ffebe80: 00000100 3fff7343 3fff56f8 4022e920
            3ffebe90: 00000000 000000d0 3ffebec0 00000030
            3ffebea0: 23d24220 94505eb8 343d9c13 00000004
            3ffebeb0: 3fff8710 3fff7310 3fff733d 4022a976
            3ffebec0: 4b980203 168029df c6c4081b 75a2510b
            3ffebed0: f0c26116 a3aa5ece 637434da f43db536
            3ffebee0: 5de87775 4b7f6e2d f5cbbbf8 3ace6804
            3ffebef0: 3fff733d 3fff8710 3fff7310 4022ad09
            3ffebf00: f2fedcf8 0187f7fa 8c83b36b 3fff5180
            3ffebf10: 00000000 00000004 00000004 402044b3
            3ffebf20: 3fff7341 3fff733d 3fff5310 00001240
            3ffebf30: 000012a0 3fff85bf 0000001d 00000004
            3ffebf40: 3fff7310 3fff733d 00000004 00000004
            3ffebf50: 3fff733d 3fff8710 3fff7310 4022a79e
            3ffebf60: 00000038 00000000 3fff5180 4020430e
            3ffebf70: 00000038 00000001 00000033 3fff7338
            3ffebf80: 00000000 00020010 0000000e 00000010
            3ffebf90: 00000004 401000a2 3ffeadd8 4020436c
            3ffebfa0: 3fff8710 00000033 00000016 00000000
            3ffebfb0: 3fff8710 3fff7310 3fff7310 4022a8da
            3ffebfc0: 3fff8710 3fff733d 3fff7310 4022aab1
            3ffebfd0: 00000000 3fff51d8 3fff7310 4022ab3a
            3ffebfe0: 3fff6cf0 402058f2 3ffeadd8 3ffeb040
            3ffebff0: 3fff5250 3fff51b8 3ffeadd8 4020416e
            3ffec000: c6a79a95 00000001 3ffec0d4 3ffec0b0
            3ffec010: 3ffea0f8 3ffeadd8 3ffeadd8 402043e0
            3ffec020: 3ffe9780 c6a79a95 3ffec1a8 40206a21
            3ffec030: 401000b4 3ffec0b0 3ffec0d4 4020544e
            3ffec040: 3ffe9780 c6a79a95 3ffec0b0 00000044
            3ffec050: 00000043 00000001 3fff4e80 0000000f
            3ffec060: 00000000 3fff4e60 0000000f 00000002
            3ffec070: 3ffe9780 c6a79a95 3ffec0b0 40207b4a
            3ffec080: 3ffec1a8 3ffea814 3ffec0b0 40207c4c
            3ffec090: 3ffec1a8 3ffea814 00000000 3ffec120
            3ffec0a0: 3ffec1a8 3ffea814 00000000 40205573
            3ffec0b0: 3fff4e00 0000004f 00000044 00000001
            3ffec0c0: 3ffec1a8 0000000b 3ffe92fb 40207ac2
            3ffec0d0: 3fff3bf0 3fff4ea0 0000000f 00000000
            3ffec0e0: 3fff4d90 0000004f 00000044 40207b4a
            3ffec0f0: 3fffdc20 00000000 3ffec120 40207c4c
            3ffec100: 4f00a8c0 00ffffff 3ffea810 3ffec17c
            3ffec110: 3fffdc20 00000000 3ffea810 402022f2
            3ffec120: 3fff4ad0 0000000f 00000001 00000000
            3ffec130: 00000000 00000000 3ffec174 40201896
            3ffec140: 00000000 00000000 3ffeb130 40100398
            <<<stack<<<

ets Jan 8 2013,rst cause:2, boot mode:(1,7)

ets Jan 8 2013,rst cause:4, boot mode:(1,7)

wdt reset

Please, can you see why this erros?
User avatar
By Giancarlo
#30455 Hi,
The reason is simple, the library you used is not the proper one.
This library is the one to be used with WiFi101 shield that is a brandnew product from Arduino that will be available very soon.
When I wrote you, there was the ESP8266TelegramBot library in my repo, now it is no longer there :-)
I can send the correct library to you in attachment.
ciao.
Attachments
(5.86 KiB) Downloaded 938 times