PHP 朗文电报机器人。无法通过网络钩子下载文件



我在Yii2项目中使用longman/telegram bot包。

class GenericmessageCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'genericmessage';
/**
* @var string
*/
protected $description = 'Handle generic message';
/**
* @var string
*/
protected $version = '1.0.0';
/**
* Main command execution
*
* @return ServerResponse
*/
public function execute(): ServerResponse
{
$message = $this->getMessage();
if (in_array($message->getType(), ['audio', 'document', 'photo', 'video', 'voice'])) {
$doc = call_user_func([$message, 'get' . $message->getType()]);
($message->getType() === 'photo') && $doc = end($doc);
$photoId = $doc->file_id;
$download_path = $this->telegram->getDownloadPath();
$file    = Request::getFile(['file_id' => $photoId]);
if ($file->isOk() && Request::downloadFile($file->getResult())) {
return $this->replyToChat(' file is located at: ' . $download_path . '/' . $file->getResult()->getFilePath());
} else {
return $this->replyToChat('Failed to download.');
}
}
}
}

就像

当我使用getUpdates方法时,它运行良好https://github.com/php-telegram-bot/core#getupdates-安装

但当我使用WebHooks时,它不起作用。尽管我从我的机器人那里得到了相同的答案……它说";好的";以及";文件位于…";,但是没有这样的文件。

因为webhook使用了Yii2的后端高级。。。。它将所有文件存储在后端(因为我的webhook在后端(,但我在前端搜索它们(因为我很愚蠢(。

最新更新