【问题标题】:Telegram api send an already uploaded photoTelegram api 发送已上传的照片
【发布时间】:2017-12-05 04:35:00
【问题描述】:

Telegram bot api 支持发送已上传的照片。电报 api 是否也支持发送已上传的照片?

我查看了 api 文档,但找不到任何相关方法。

【问题讨论】:

    标签: telegram


    【解决方案1】:

    你可以得到file_id来响应sendPhoto,就像chat_id一样作为photo字段使用。

    例如:

    callAPI("sendPhoto", [
        "chat_id": 109780439,
        "file_id": "AAAAAAXXX"
    ]
    

    【讨论】:

    • 我在电报 API 中没有看到任何 sendphoto。你能在你找到它的地方发布一个链接吗?
    • @apadana 你是怎么上传照片的?
    【解决方案2】:

    如果你使用这个库https://github.com/TelegramBot/Api,它的工作代码:

    $chat_id = <chat_id>;
    $token = <token>;
    $bot = new \TelegramBot\Api\BotApi($token);
    
    try {
    
        $bot->sendPhoto($chat_id, <file_id>, 'caption');
    
    } catch (\TelegramBot\Api\Exception $e) {
    
        $e->getMessage();
    
    }
    

    如果没有,这是简单的 GET 方法:

    https://api.telegram.org/bot<token>/sendPhoto?chat_id=<chat_id>&photo=<file_id>
    

    更多信息Telegram Bot API

    【讨论】:

    • 感谢您的回答,但问题是关于电报 api,而不是不同的 bot api。
    猜你喜欢
    • 2018-11-12
    • 2015-11-24
    • 2016-07-09
    • 2021-04-24
    • 2017-06-06
    • 2021-10-03
    • 1970-01-01
    • 2016-03-16
    • 2021-06-28
    相关资源
    最近更新 更多