无法使用 MadelineProto 从 Telegram 中的频道获取所有消息

时间:2021-02-02 19:42:54

标签: php telegram

我想使用 MadelineProto 从电报频道获取所有消息。我根据他们的文档按照步骤操作:https://docs.madelineproto.xyz/API_docs/methods/messages.getHistory.html

这是我的代码

<?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 = '-1001433544229';
$offset_id = 0;
$limit = 100;

$messages_Messages = $MadelineProto->messages->getHistory(
    ['peer' => $channel,
    'offset_id' => 0,
    'offset_date' => 0, 
    'add_offset' => 0, 
    'limit' => $limit, 
    'max_id' => 9999999999, 
    'min_id' => 0, 
    'hash' => 0]);
echo json_encode($messages_Messages);

问题在于它返回一个空对象。问题是什么?有没有更新我们不能再从 Telegram 中的频道检索消息了?提前致谢。

1 个答案:

答案 0 :(得分:0)

询问了 madeline proto 社区的一些人后,发现解决方案只是添加

$MadelineProto->async(false)

在 $MadelineProto->start() 之后;方法。