2016-05-15 103 views
1

我写了一个带有Nodejs的Telegram bot。将图像发送到我使用下面的命令的用户:显示Node Telegram Bot API返回错误400

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); 
     }); 

此错误:

Unhandled rejection Error: 400 {"ok":false,"error_code":400,"description":"Bad Request: there is no photo in the request"}

你能帮助我吗?

回答

0

解决:

var photo = __dirname+'/../Android.png'; 
bot.sendPhoto(msg.chat.id, photo, {caption: "I'm a 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

+0

谢谢你,但问题没有解决! '未处理的拒绝错误:400 {“ok”:false,“error_code”:400,“description”:“错误的请求:请求中没有照片”} ' –