I would like to ask how to convert the object received from the API Telegram. Below is my attempt:

$Image = []; for ($i=0; $i < 100; $i++) { $photo = new \TelegramBot\Api\Types\Inline\QueryResult\Photo($i,'http://site.ru/telegram/image/'.$i.'.jpg', 'http://site.ru/telegram/thumbinals/1.jpg'); (array) $photo; $Image = $photo[$i]; } var_dump((array)$Image); $result = $bot->answerInlineQuery($qid, $Image, 100, false); 
  • $ result = (array) $ result; - Maxim Stepanov
  • You convert the object into an array and then this resulting array ... is collected by the garbage collector, since you have not assigned it anywhere. - rjhdby pm
  • Maxim Stepanov; It does not fit, because you need to convert to request. I want to make it so that there is an array of type: array ($ url1, $ url2, $ url3, ..., $ urlN). - Vitaly Kessel
  • rjhdby, not really understand you. When is it then assigned? - Vitaly Kessel

1 answer 1

I solved my problem.

 for ($i=0; $i < 10; $i++) { $photo[] = new \TelegramBot\Api\Types\Inline\QueryResult\Photo($i,'http://site.ru/telegram/image/'.$i.'.jpg', 'http://site.ru/telegram/thumbinals/1.jpg');; }