phpapitelegrammtproto

Get CHAT_WRITE_FORBIDDEN using MadelineProto with Telegram API


I'm using the MadelineProto project for php to interact with Telegram API. Maybe this error has nothing to do with MadelineProto... anyway, I successfully created a supergroup but any other method I call after, gives me a CHAT_WRITE_FORBIDDEN error. Can't find anything in Telegram Documentation about why I'm getting this error and how to solve.

This is my code:

$MadelineProto = new MadelineProtoAPI('session.madeline', $settings);
$MadelineProto->async(false);
$MadelineProto->start();

// successfully create the group
$updates = $MadelineProto->channels->createChannel([
        'megagroup' => true,
        'title' => 'Test group',
        'about' => 'Test group description',
]);
foreach($updates as $update) {

        // try to invite other users --> CHAT_WRITE_FORBIDDEN
        $updates = $MadelineProto->channels->inviteToChannel([
            'channel' => $update,
            'users' => ['@#######']
        ]);

        // try to change admin rights --> CHAT_WRITE_FORBIDDEN
        $updates = $MadelineProto->channels->editAdmin([
            'channel' => $update,
            'user_id' => '@#######',
            'admin_rights' => [
                '_' => 'chatAdminRights',
                'change_info' => true,
                'post_messages' => true,
                'edit_messages' => true,
                'delete_messages' => true,
                'ban_users' => true,
                'invite_users' => true,
                'pin_messages' => true,
                'add_admins' => true,
                'anonymous' => true,
            ],
            'rank' => ''
        ]);
}

What I'm doing wrong?

Thanks


Solution

  • It seems that the problem was due to the value passed to the 'channel' property. Instead of passing the $update variable, I passed directly the channel id in the form "channel#1234567890" and finally got a correct answer from Telegram.