Hi, I can not send a photo to telegrams from yii2, when I try to send a photo, I get the following error: Too few arguments to function TelegramBot\Api\BotApi::sendPhoto(), 1 passed in D:\OpenServer\domains\univer.lc\controllers\TelegramController.php on line 27 and at least 2 expected Here is the code

 Yii::$app->bot->sendPhoto([ 'chat_id' => '-1001320591192', 'photo' => Yii::getAlias('@app/web/images/hello.jpg'), 'caption' => 'Найдите меня!' ]); 
  • What exactly is not clear to you in what is written to you in response to your actions? sentPhoto expects at least the second parameter, you transmit one. - zalex

1 answer 1

The library method (component Yii2) you are using expects at least 2 parameters. Read the documentation carefully or see in the source code what input parameters are expected.

UPD: if you use the yii2-developer/telegram-bot library, then the call to this function will be as follows

 Yii::$app->bot->sendPhoto(-1001320591192, Yii::getAlias('@app/web/images/hello.jpg'), 'Найдите меня!'); 
  • I use the SonkoDmitry / yii2-telegram-bot-api extension - SHEROZ Juraev
  • @sherozjuraev in this case, the SonkoDmitry/yii2-telegram-bot-api library is inherited from TelegramBot/Api and has the same API as I described above - Evgeny