Answer the question
In order to leave comments, you need to log in
How to download photos from a telegram channel using Madeline?
I am using MadelineProto
I need to get a photo from the latest telegram post
The code I am using is:
<?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");
Answer the question
In order to leave comments, you need to log in
As it turned out, Madeline went a little crazy
. All you had to do was add the __DIR__ constant.
The last line of code:
$MadelineProto->downloadToFile($message, __DIR__ . "/tmp.png");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question