【问题标题】:Node Telegram Bot API return Bad Request: there is no photo in the requestNode Telegram Bot API 返回错误请求:请求中没有照片
【发布时间】:2016-09-11 04:47:37
【问题描述】:

我用 Nodejs 编写了一个 Telegram 机器人。要将图像发送给用户,我使用以下命令:

bot.sendPhoto({
            chat_id: msg.chat.id,
            caption: 'Test caption',
            files: {
                photo: '../change-db-shop-url.png'
            }
        }, function (err, msg) {
            console.log(err);
            console.log(msg);
        });

显示此错误:

未处理的拒绝错误:400 {"ok":false,"error_code":400,"description":"错误请求:没有 请求中的照片”}

你能帮帮我吗?

【问题讨论】:

    标签: node.js telegram-bot


    【解决方案1】:

    应该是:

    bot.sendPhoto({
      chatId: msg.chat.id,
      caption: 'Test caption',
      photo: '../change-db-shop-url.png'
    }, function(err, msg) {
      console.log(err);
      console.log(msg);
    });
    

    https://github.com/yagop/node-telegram-bot-api#TelegramBot+sendPhoto

    【讨论】:

    • 谢谢,但是问题没有解决! ‍‍‍‍‍Unhandled rejection Error: 400 {"ok":false,"error_code":400,"description":"Bad Request: there is no photo in the request"}
    【解决方案2】:

    【讨论】:

    【解决方案3】:

    已解决:

    var photo = __dirname+'/../Android.png';
    bot.sendPhoto(msg.chat.id, photo, {caption: "I'm a bot!"});
    

    【讨论】:

      【解决方案4】:

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-03-08
        • 1970-01-01
        • 2016-03-16
        • 2018-09-13
        • 2015-09-20
        • 1970-01-01
        • 1970-01-01
        • 2019-11-12
        相关资源
        最近更新 更多