2016-05-15 100 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」:「錯誤的請求:請求中沒有照片」} ' –