Я использую MadelineProto
Мне нужно получить фотографию из последнего поста в телеграмм
Код который я использую:
<?php
if (!file_exists('madeline.php')) {
copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
}
include 'madeline.php';
$MadelineProto = new \danog\MadelineProto\API('session.madeline');
$MadelineProto->start();
$channel = '@example';
$offset_id = 0;
$limit = 1;
$messages_Messages = $MadelineProto->messages->getHistory(['peer' => $channel, 'offset_id' => $offset_id, 'offset_date' => 0, 'add_offset' => 0, 'limit' => $limit, 'max_id' => 0, 'min_id' => 0, 'hash' => 0 ]);
$message = $messages_Messages['messages'][0];
echo json_encode($message);
$MadelineProto->downloadToFile($message, "/tmp.png");
$message{"_":"messageMediaPhoto","photo":{"_":"photo","has_stickers":false,"id":5**54901******2695,"access_hash":-82*****8334,"file_reference":{"_":"bytes","bytes":"AkV4QiEAABFvYFze*****QoZFrTBH7fvQ="},"date":1616692497,"sizes":[{"_":"photoStrippedSize","type":"i","bytes":{"_":"bytes","bytes":"ASgdpA8dV\/EU0n*****FFJjTA=="}},{"_":"photoSize","type":"m","location":{"_":"fileLocationToBeDeprecated","volume_id":4****0743,"local_id":44***85},"w":231,"h":320,"size":12760},{"_":"photoSize","type":"x","location":{"_":"fileLocationToBeDeprecated","volume_id":4000****43,"local_id":44***6},"w":502,"h":696,"size":36269}],"dc_id":4}}
Данные по фото приходят, но файл не создается, в чем проблема?
Заранее спасибо