【发布时间】:2021-02-07 15:41:21
【问题描述】:
我在电报机器人中遇到了几天的问题。我在 php 中的电报机器人中开发了一个系统,其中有人在Telegram Group 中发短信,并且自动回复来自组,正如他/她所期望的那样。它适用于像下面这样的网站
https://api.telegram.org/botmy_token/setwebhook?url=https://example.com/bot/index.php
my_token 是 Bot Father Token
但是当我在下面这样使用时
https://api.telegram.org/botmy_token/setwebhook?url=https://xxx.xxx.xx.xx/DevOps2019/onmv4_1/index.php?e=pabx&p=all_list&f=all&l=sp_bot.php
或者
https://api.telegram.org/botmy_token/setwebhook?url=https://example.net/DevOps2019/onmv4_1/index.php?e=pabx&p=all_list&f=all&l=sp_bot.php
它显示了一个错误
{"ok":false,"error_code":400,"description":"Bad Request: bad webhook: IP address xxx.xxx.xx.xx is reserved"}
注意:
https://example.net/DevOps2019/onmv4_1/index.php?e=pabx&p=all_list&f=all&l=sp_bot.php
以上链接为专用网络。不允许公开访问。我的问题是如何在电报机器人中将上述链接设置为 webhook。
【问题讨论】:
-
"不允许公开访问";所以电报无法访问它,因此您不能将其用作 webhook url? Telegram 需要能够解析地址并向脚本发送请求。
-
@0stone0,感谢您的评论。有任何替代解决方案来解决问题吗?
-
您期望得到什么答案?这就是 web-hooks 的工作方式,server1(电报)需要能够向 server2(您的机器)发送请求。如果该路由不公开可用,则没有办法...您应该使用公开可用的域/IP。
标签: php telegram telegram-bot