Looking to hire Laravel developers? Try LaraJobs

shad-serializer-laravel maintained by disintegrations

Description
Laravel client for serializing and sending encrypted Shad Messenger requests.
Last update
2026/06/15 15:23 (dev-main)
License
Links
Downloads
0

Comments
comments powered by Disqus

Shad Serializer

Laravel client for serializing, encrypting, signing, sending, and decrypting Shad Messenger HTTP API requests.

This is an unofficial package based on observed Shad web-client behavior. The protocol is undocumented and may change.

Installation

Requires PHP 8.4 or newer, OpenSSL, and Laravel 12 or newer. GitHub Actions tests the package on PHP 8.4 and PHP 8.5.

composer require disintegrations/shad-serializer-laravel

Laravel package discovery registers the service provider automatically.

Configuration

php artisan vendor:publish --tag=shad-config
SHAD_API_URL=https://shadmessenger2.iranlms.ir
SHAD_API_VERSION=6
SHAD_APP_VERSION=4.4.26
SHAD_LANGUAGE=fa
SHAD_TIMEOUT=20

For an existing session, configure SHAD_AUTH and SHAD_PRIVATE_KEY_PEM. API v6 authorized requests require both values. Keep them secret.

Usage

use Disintegrations\ShadSerializer\ShadClient;

$shad = app(ShadClient::class);

$sent = $shad->sendCode('98912...');
$session = $shad->signIn('98912...', $sent['phone_code_hash'], '123456');
$shad->registerDevice();
$shad->saveState(storage_path('app/shad-state.json'));

$chats = $shad->getChats();
$shad->sendMessage('u0...', 'Hello from Laravel');
$shad->sendFile('u0...', storage_path('app/document.pdf'));

Load a saved session without Laravel's container:

$shad = ShadClient::loadState(storage_path('app/shad-state.json'));
$result = $shad->callData('getMySessions');

Use the facade:

use Disintegrations\ShadSerializer\Facades\Shad;

$chats = Shad::getChats();

Use the protocol serializer directly:

use Disintegrations\ShadSerializer\Protocol\ShadProtocol;

$encrypted = ShadProtocol::encryptData(['method' => 'example'], $auth);
$decoded = ShadProtocol::decryptData($encrypted, $auth);

The client also includes the Python package's chat, message, contact, channel, folder, data-center discovery, multipart upload, and ranged download helpers.

Testing

composer install
composer test