我得到file_get_contents
的否定回复,如下所示
Telegram Bot PHP:警告:file_get_contents无法打开流:400 Bad Request
上下文代码
ini_set("error_reporting", E_ALL); $botToken = "249706675:AAGGJtFStHf6zbuQfbAClcGzzlFz75xqFKA"; $website = "https://api.telegram.org/bot".$botToken; $update = file_get_contents("php://input"); $updateArray = json_decode($update, TRUE); $chatId = $updateArray["result"][0]["message"]["chat"]["id"]; $message = $updateArray["message"]["text"]; switch($message) { case "/hello": sendMessage($chatId, "Hello!"); break; case "/wtf": sendMessage($chatId, "I'm personal bot of @TCGroup!"); break; default: sendMessage($chatId, "Default"); } function sendMessage($chatId, $message) { $url = $GLOBALS["website"]."/sendmessage?chat_id=".$chatId."&text=".urlencode($message); file_get_contents($url); }
答案 0 :(得分:0)
尝试驼峰式将sendMessage放在URL中。并使用cURL扩展名代替file_get_contents,因为它更有效。