downloadToFile方法madelineproto电报

问题描述

我正在尝试从自己的服务器上的电报服务器下载某些媒体,我找到了某些媒体的文件ID,并以此方式使用它:

    $new = 'CQACAgQAAxkBAAJHK18z8msj9lgi....';

$info = yield $MadelineProto->getDownloadInfo($new);
$output_file_name = yield $MadelineProto->downloadToFile($info,'10.mp3');

它创建了一个0 KB的文件,现在有人吗?

我也尝试使用onUpdateNewMessage方法获取文件ID,但是它返回了一个没有任何文件ID的数组,我试图在downloadToFile中使用它,但它甚至没有创建任何文件!!!

我尝试过

$output_file_name = yield $MadelineProto->downloadToFile($update,'10.mp3');

没有成功

$info = yield $MadelineProto->getDownloadInfo($update);
$output_file_name = yield $MadelineProto->downloadToFile($info,'10.mp3');

没有成功

$botAPI_file = yield $MadelineProto->MTProtoToBotAPI($update);
            
            
            foreach (['audio','document','photo','sticker','video','voice','video_note'] as $type) {
    if (isset($botAPI_file[$type]) && is_array($botAPI_file[$type])) {
        $method = $type;
    }
}
$result['file_type'] = $method;
if ($result['file_type'] == 'photo') {
    $result['file_size'] = $botAPI_file[$method][0]['file_size'];
    if (isset($botAPI_file[$method][0]['file_name'])) {
        $result['file_name'] = $botAPI_file[$method][0]['file_name'];
        $result['file_id'] = $botAPI_file[$method][0]['file_id'];
    }
} else {
    if (isset($botAPI_file[$method]['file_name'])) {
        $result['file_name'] = $botAPI_file[$method]['file_name'];
    }
    if (isset($botAPI_file[$method]['file_size'])) {
        $result['file_size'] = $botAPI_file[$method]['file_size'];
    }
    if (isset($botAPI_file[$method]['mime_type'])) {
        $result['mime_type'] = $botAPI_file[$method]['mime_type'];
    }
    $result['file_id'] = $botAPI_file[$method]['file_id'];
}
if (!isset($result['mime_type'])) {
    $result['mime_type'] = 'application/octet-stream';
}
if (!isset($result['file_name'])) {
    $result['file_name'] = $result['file_id'].($method === 'sticker' ? '.webp' : '');
}
            
            
            
            $output_file_name = yield $MadelineProto->downloadToFile($result['file_id'],'2.mp3');

我要做的就是将所有发送到特定机器人的媒体下载到我的服务器上。 有人可以帮助我吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...