arrow_back
Back

MadelineProto installation, sessions, and API credentials

Andrew Dorokhov Andrew Dorokhov schedule 1 min read
menu_book Table of Contents

Installation

Official docs: open_in_new Installation .

Sessions

To store account session data and avoid logging in again, the session must be serialized.

A MadelineProto session is automatically serialized every $MadelineProto->settings['serialization']['serialization_interval'] seconds (30 seconds by default), and on shutdown. If the script shuts down normally (without Ctrl+C or fatal errors/exceptions), the session is also serialized automatically.

Create the session and set the serialization destination file:

$MadelineProto = new \danog\MadelineProto\API('session.madeline', $settings);
// The session will be serialized to session.madeline

Load a serialized session the same way:

$MadelineProto = new \danog\MadelineProto\API('session.madeline', $settings);
// The session will be loaded from session.madeline

Change the session file after starting MadelineProto:

$MadelineProto->session = 'newsession.madeline';

API ID and hash

You must register an application (it is tied to a Telegram account). Do that at open_in_new my.telegram.org .

You will get two values:

api_id
api_hash
code

Need Help with Development?

Happy to help — reach out via the contacts or go straight to my Upwork profile.

work View Upwork Profile arrow_forward