【问题标题】:Telegram BOT, send message with gif attachmentTelegram BOT,发送带有 gif 附件的消息
【发布时间】:2019-11-08 21:01:50
【问题描述】:

我使用此代码通过 BOT 发送图像 https://stackoverflow.com/a/32296353/6017365,一切都很好:

$bot_url    = "https://api.telegram.org/bot<bot_id>/";
$url        = $bot_url . "sendPhoto?chat_id=" . $chat_id ;

$post_fields = array('chat_id'   => $chat_id,
    'photo'     => new CURLFile(realpath("/path/to/image.png"))
);

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "Content-Type:multipart/form-data"
));
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); 
$output = curl_exec($ch);

然后我修改它以发送带有sendVideovideo参数的gif。

现在我想编辑文件以发送带有 gif 作为附件的普通文本....我尝试在数组中添加 text 参数,但只收到图像... 有什么建议吗?

【问题讨论】:

  • 尝试使用caption而不是text(文本用于短信,标题用于照片、视频和相册)

标签: php bots telegram


【解决方案1】:

只是为了澄清@AliKhalili 的回应;

sendVideo 接受一个名为caption可选 参数来向视频添加一些文本。

不像sendMessage 使用必填 text 字段。

【讨论】:

    猜你喜欢
    • 2018-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-17
    • 2016-05-09
    • 2018-02-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多