我想从频道下载所有照片。尝试使用https://github.com/danog/MadelineProto获取频道消息历史记录:
$MadelineProto->messages->getHistory([
'peer' => "-100xxxxxx",
'offset_id' => 0,
'offset_date' => 0,
'add_offset' => 0,
'limit' => 25,
'max_id' => 1000,
'min_id' => 0,
'hash' => 1,
]);
结果我得到了一系列带媒体的消息:
array(13) {
["_"] => string(7) "message"
["out"] => bool(false)
["mentioned"] => bool(false)
["media_unread"] => bool(false)
["silent"] => bool(false)
["post"] => bool(false)
["id"] => int(38)
["from_id"] => int(500100000)
["to_id"] => array(2) {
["_"] =>string(11) "peerChannel"
["channel_id"] =>int(1369700000)
}
["date"] => int(1520150410)
["message"] => string(0) ""
["media"] => array(2) {
["_"] =>string(17) "messageMediaPhoto"
["photo"] =>array(6) {
["_"] => string(5) "photo"
["has_stickers"] => bool(false)
["id"] => int(5251753100000000000)
["access_hash"] => int(-6118957000000000000)
["date"] => int(1520150405)
["sizes"] => array(4) {
[0] =>array(6) {
["_"] => string(9) "photoSize"
["type"] => string(1) "s"
["location"] => array(5) {
["_"] =>string(12) "fileLocation"
["dc_id"] =>int(2)
["volume_id"] =>int(235100000)
["local_id"] =>int(250000)
["secret"] =>int(5193339136300000000)
}
["w"] => int(90)
["h"] => int(67)
["size"] => int(1078)
}
....
现在我想下载这个文件并且不知道怎么做。方法https://core.telegram.org/bots/api#getfile请求 file_id ,但我没有。
消息历史记录只给我这张照片参数:
如何从可用数据中获取file_id或生成它?
或者如何通过其他方式从频道历史记录中下载照片?
答案 0 :(得分:1)
MadelineProto具有未记录的功能,如 download_to_file 或 download_to_dir 。
async