PHP打造Telegram机器人开发实战指南
流量次数: 作者:tg下载 发布时间:2025-08-15 14:30
namespace appcontroller;
use thinkRequest;
class BotController {
public function handle(Request $request) {
$input = json_decode(file_get_contents('php://input'), true);
$chatId = $input['message']['chat']['id' ?? null;
$text = $input['message']['text' ?? '';
// 关键词回复示例
if (preg_match('//start/i', $text)) {
$reply = "欢迎使用!输入 /help 查看功能";
file_get_contents(" .
http_build_query(['chat_id' => $chatId, 'text' => $reply]));
下一篇:没有了