how to use setwebhook in telegram?
Asked Answered
W

4

15

Hello I'm creating a bot in telegram. I send a http request:
https://api.telegram.org/bot(mytoken)/setWebhook?url=https://mywebpagetorespondtobot

and I receive this:

{"ok":true,"result":true,"description":"Webhook was set"}

but It doesn't work.I mean telegram doesn't send updates to the server. Is this because I didn't upload my certificate?how should I do that then?

Wimble answered 28/4, 2016 at 4:46 Comment(3)
how do you recive updates?Greathearted
When I delete the webhook, getUpdates() works fineWimble
do you use self-Signed certificate?Greathearted
H
13

Check the status of your updates here:

https://api.telegram.org/botYOUR_TOKEN/getWebhookInfo

It will tell you about any errors. Should you not see any problems here the issue is to be found somewhere in your script. Make sure to handle incoming updates correctly.

It might be a problem with self-signed certificate. It needs to be uploaded via setWebhook method first as described here. Or try a more extensive guide here.

Hanschen answered 28/4, 2016 at 9:25 Comment(1)
I deleted the webhook and getUpdates() worked fine.Maby the problem is with the certificate.I read the link but I don't know how to generate and send the pem fileWimble
W
6

I changed the setwebhook url to a and it worked.it seems that it doesn't work with a wabepage url. https://api.telegram.org/bot(mytoken)/setWebhook?url=https://mywebpagetorespondtobot/mymethod ' (the WebMethod)

Wimble answered 10/5, 2016 at 6:10 Comment(0)
L
6

It's means what your public key incorrect.

You may check it by url https://api.telegram.org/bot{token}/getWebhookInfo after setting

When i sent incorrect public key - i receive

{"ok":true,"result":{"url":"","has_custom_certificate":false,"pending_update_count":6}}

but if i sent correct public key, i receive:

{"ok":true,"result":{"url":"mycorrecturl.com","has_custom_certificate":true,"pending_update_count":6,"last_error_date":1506772578,"last_error_message":"SSL error {337047686, error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed}","max_connections":40}}
Leicester answered 30/9, 2017 at 11:58 Comment(0)
E
0
  1. BotFather -> Bot list -> API Token -> Revoke current token
  2. https://api.telegram.org/bot(New token)/setWebhook?url=https://myweb... Done)
Eaglestone answered 21/9, 2021 at 12:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.