Eleirbag89 / TelegramBotPHP

A very simple PHP Telegram Bot API for sending messages.
http://eleirbag89.github.io/TelegramBotPHP
MIT License
807 stars 341 forks source link

How can i get image and caption from message when user send? #168

Closed farshidmousavi closed 5 years ago

farshidmousavi commented 5 years ago

i have a problem. how can i get image (image id) and image caption and send it to anyone (or himself)

$data = $telegram->getData(); if(isset($data['message']['photo'])){ $Photo = $data['message']['photo']; } if(isset($data['message']['caption'])){ $caption = $data['message']['caption']; } $content = array('chat_id' => $chat_id, 'reply_markup' => $keyb,'photo' => $Photo, 'caption' => $caption); $telegram->sendPhoto($content);

Where is problem? Error returned PHP Notice: Array to string conversion in /home/mysite/public_html/telegrambot/bot.php on line 3058

farshidmousavi commented 5 years ago

i found my fault. $Photo = $data['message']['photo']; must be $Photo = $data['message']['photo'][0]['file_id'];