【问题标题】:Unable to get all messages from a channel in Telegram with MadelineProto无法使用 MadelineProto 从 Telegram 中的频道获取所有消息
【发布时间】:2021-05-09 12:09:04
【问题描述】:

我想使用 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 的频道中检索消息了?提前致谢。

【问题讨论】:

  • 看看能不能得到错误码。也许缺少身份验证令牌?我想知道'session.madeline' 的字符串是干什么用的,有相关文档吗?
  • @dreua 其他方法有效,所以它不是身份验证令牌问题。 'session.madeline' 用于保存我与电报的会话。

标签: php telegram


【解决方案1】:

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

$MadelineProto->async(false)

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

【讨论】:

    猜你喜欢
    • 2022-08-11
    • 2016-04-04
    • 2022-07-17
    • 2021-01-19
    • 1970-01-01
    • 2021-07-10
    • 1970-01-01
    • 1970-01-01
    • 2020-12-23
    相关资源
    最近更新 更多