I am using this Telegram Bot API for NodeJS https://github.com/yagop/node-telegram-bot-api and there is a method “getUserProfilePhotos”, I used it and got error:
"Bad Request: there is no photo in the request"
Here is my code
var TelegramBot = require('node-telegram-bot-api');
var token = '********************************************';
var bot = new TelegramBot(token, {polling: true});
bot.on('message', function (msg) {
var chatId = msg.chat.id;
var userId = msg.from.id;
bot.sendMessage(chatId,"There is something");
bot.sendPhoto(chatId,bot.getUserProfilePhotos(userId, 1, 1) ,{caption: "It's your photo!"});
});
I have a Profile Photo in my telegram accaunt. I dont know what to do. Can someone help me? Sorry for my eng)
2
Answers
try this, work correctly:
getUserProfilePhoto returns an UserProfilePhotos with photos attribute containing the list of user profile. Beside getUserProfilePhoto method want as second parameter photo id not photo object.
Arrays Base Index Number is 0
But you use 1 and 1! in this line:
bot.sendPhoto(chatId,bot.getUserProfilePhotos(userId, 1, 1) ,{caption: "It's your photo!"});
Correct it to :
bot.sendPhoto(chatId,bot.getUserProfilePhotos(userId, 0, 0) ,{caption: "It's your photo!"});