xtrime-ru / TelegramApiServer

Fast, simple, async php telegram api server: MadelineProto + Amp HTTP Server
https://tg.i-c-a.su
MIT License
576 stars 130 forks source link

Problem with downloading files after update #131

Closed Arrivederchi closed 1 year ago

Arrivederchi commented 1 year ago

I used this code to download files, but now it returns null, what to do?

if ($message['media']['_'] == 'messageMediaPhoto') {

                $url = 'http://ip:9503/api/downloadToDir';

                $data = array('media' => $message['media'], 'images/tg/');

                $postdata = json_encode($data);

                $ch = curl_init($url);
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
                $result = curl_exec($ch);
                curl_close($ch);
                $result = json_decode($result, true);

                var_dump($result);      

}
xtrime-ru commented 1 year ago

Check logs

Arrivederchi commented 1 year ago
[2023-05-22 16:54:39] [error] No such file or directory

[2023-05-22 16:54:39] [error] Unexpected JsonException with message 'Type is not supported' thrown from /app-host-link/src/Controllers/AbstractApiController.php:236 when handling request: POST http://ip_сервера:9503/api/downloadToDir HTTP/1.1 ip_с_которого_запрос:36486 on 172.20.0.3:9503
{
    "exception": {},
    "method": {},
    "uri": "http://ip_сервера:9503/api/downloadToDir",
    "protocolVersion": "1.1",
    "local": "172.20.0.3:9503",
    "remote": "ip_с_которого_запрос:36486"
}
[2023-05-22 16:54:39] [error] No such file or directory

[2023-05-22 16:54:39] [error] Unexpected JsonException with message 'Type is not supported' thrown from /app-host-link/src/Controllers/AbstractApiController.php:236 when handling request: POST http://ip_сервера:9503/api/downloadToDir HTTP/1.1 ip_с_которого_запрос:36488 on 172.20.0.3:9503
{
    "exception": {},
    "method": {},
    "uri": "http://ip_сервера:9503/api/downloadToDir",
    "protocolVersion": "1.1",
    "local": "172.20.0.3:9503",
    "remote": "ip_с_которого_запрос:36488"
}
[2023-05-22 16:54:39] [error] No such file or directory

[2023-05-22 16:54:39] [error] Unexpected JsonException with message 'Type is not supported' thrown from /app-host-link/src/Controllers/AbstractApiController.php:236 when handling request: POST http://ip_сервера:9503/api/downloadToDir HTTP/1.1 ip_с_которого_запрос:36490 on 172.20.0.3:9503
{
    "exception": {},
    "method": {},
    "uri": "http://ip_сервера:9503/api/downloadToDir",
    "protocolVersion": "1.1",
    "local": "172.20.0.3:9503",
    "remote": "ip_с_которого_запрос:36490"
}
Arrivederchi commented 1 year ago

directory TelegramApiServer/images/tg exist

xtrime-ru commented 1 year ago

Thanks for report.

Its a bug with EIO async driver. Temporary switched to sync touch: https://github.com/danog/MadelineProto/commit/ea44d93f1c5a8898f25bc5fd04a097de835e7acc

Also fixed error message generation: https://github.com/xtrime-ru/TelegramApiServer/commit/149149b2815284ac6f5f8808459ef04a052cffd5

Please git pull && composer install