Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use setwebhook in telegram?

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?

like image 473
amir mola Avatar asked Apr 28 '16 04:04

amir mola


3 Answers

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.

like image 181
newsha Avatar answered Oct 17 '22 03:10

newsha


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)

like image 5
amir mola Avatar answered Oct 17 '22 02:10

amir mola


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}}
like image 5
Nikolas Sumrak Avatar answered Oct 17 '22 02:10

Nikolas Sumrak