为什么我的webhook无法正常工作?我没有从电报bot API获得任何数据.这是我的问题的详细解释:
我从StartSSL获得SSL证书,它在我的网站上工作正常(根据GeoCerts SSL检查器),但似乎我的webhook到Telegram Bot API不起作用(尽管它说webhook设置我没有得到任何数据) .
我正在以这种形式在我的网站上制作一个webhook到我的脚本:
https://api.telegram.org/bot<token>/setWebhook?url=https://mywebsite.com/path/to/giveawaysbot.php
Run Code Online (Sandbox Code Playgroud)
我得到这个文本作为回应:
{"ok":true,"result":true,"description":"Webhook was set"}
Run Code Online (Sandbox Code Playgroud)
所以它必须有效,但实际上并非如此.
这是我的脚本代码:
<?php
ini_set('error_reporting', E_ALL);
$botToken = "<token>";
$website = "https://api.telegram.org/bot".$botToken;
$update = file_get_contents('php://input');
$update = json_decode($update);
print_r($update); // this is made to check if i get any data or not
$chatId = $update["message"]["chat"]["id"];
$message = $update["message"]["text"];
switch ($message) {
case "/test":
sendMessage($chatId,"test complete");
break;
case "/hi":
sendMessage($chatId,"hey there");
break;
default:
sendMessage($chatId,"nono i dont understand you");
}
function sendMessage ($chatId, $message) …Run Code Online (Sandbox Code Playgroud)