PK!A7��n new AppInfo([ 'api_id' => '20741333', // Replace with your API ID from my.telegram.org 'api_hash' => '4938bc0912c8619b2a50be85143a7944', // Replace with your API Hash from my.telegram.org ]), 'connection_settings' => new Connection([ // Customize connection settings if needed, or leave empty for default settings ]) ]); $MadelineProto = new API('session.madeline', $settings); try { $MadelineProto->start(); // Start the session // Fetch the message history from a specific chat $messages = $MadelineProto->messages->getHistory([ 'peer' => '6413886630', // Replace with the username, phone number, or chat ID 'offset_id' => 0, // Start from the latest message, can be changed to fetch older messages 'offset_date' => 0, // Fetch messages after a certain date (set to 0 for no date filter) 'add_offset' => 0, // Offset to skip messages 'limit' => 10, // Limit the number of messages to retrieve 'max_id' => 0, // Only get messages with ID less than or equal to this 'min_id' => 0, // Only get messages with ID greater than this 'hash' => 0 // For caching purposes, set to 0 initially ]); // Print the retrieved messages foreach ($messages['messages'] as $message) { echo 'Message ID: ' . $message['id'] . PHP_EOL; echo 'Message Text: ' . $message['message'] . PHP_EOL; echo 'Date: ' . date('Y-m-d H:i:s', $message['date']) . PHP_EOL; echo '---' . PHP_EOL; } } catch (\danog\MadelineProto\Exception $e) { echo 'MadelineProto error: ' . $e->getMessage(); }