【发布时间】:2020-05-03 05:46:19
【问题描述】:
我正在使用一个简单的机器人代码,它从使用以下方法创建的 php 页面获取图像:
header("Content-type: image/png");
和
imagepng();
这是机器人代码:
if ($text == "/photo") {
$reply_markup = [
"inline_keyboard" => [
[
[
"text" => "Url",
"url" => "https://google.com",
],
],
],
];
sendPhoto($chat_id, "https://url.com/image.php?x=".urlencode($string), "Text", "HTML", false, $message_id, $reply_markup);
}
function sendPhoto($chat_id, $photo, $caption, $parse_mode = "default", $disable_notification = "default", $reply_to_message_id, $reply_markup) {
global $config;
if ($parse_mode == "default") $parse_mode = $config['parse_mode'];
if ($disable_notification === "default") $disable_notification = $config['disable_notification'];
$args = [
"chat_id" => $chat_id,
"photo" => $photo,
"caption" => $caption,
"parse_mode" => $parse_mode,
"disable_notification" => $disable_notification,
];
if (isset($reply_to_message_id)) $args["reply_to_message_id"] = $reply_to_message_id;
if (isset($reply_markup)) $args["reply_markup"] = $reply_markup;
return json_decode(http_request("sendPhoto", $args), true);
}
代码运行良好,并且可以正确发送图像。但是如果我两次使用相同的 url,它会向我发送之前发送的旧版本。
例如,我请求 ?x=photo 并且它正确打印 photo.png,一段时间后我再次请求照片(现在 php 页面给了我另一个图像)但机器人向我发送了旧照片。好像在 Telegram 上缓存了
【问题讨论】:
标签: php telegram-bot php-telegram-bot