入口文件index.php
<?php
require 'CallBack.php';
// 处理回调请求逻辑
$bot = new CallBack();
// 请求方式
if (isset($_GET['method'])) {
$method = $_GET['method'];
if (method_exists($bot, $method)) {
return $bot->$method();
} else {
echo "没有该功能";
die();
}
} else {
echo "调用哪个功能?";
die();
}
CallBack.php
<?php
require 'Config.php';
class CallBack
{
private $botApiKey;
private $hookUrl;
private $winiUrl;
public function __construct()
{
$config = new Config();
$this->hookUrl = $config->getUrl();
$this->botApiKey = $config->getApiKey();
$this->winiUrl = $config->getwini();
}
public function index()
{
phpinfo();
}
// 设置回调地址
public function set_callback_url() {
$deleteResponse = $this->sendCurlRequest("https://api.telegram.org/bot{
$this->botApiKey}/deleteWebhook");
print_r($deleteResponse);