TelegramBot / Api

Native PHP Wrapper for Telegram BOT API
MIT License
1.07k stars 324 forks source link

How to implement LoginUrl button with \TelegramBot\Api\Types\Inline\InlineKeyboardMarkup? #321

Closed phpony closed 1 year ago

phpony commented 3 years ago

Hi!

There's an Inline Keyboard button called "LoginUrl" in docs: https://core.telegram.org/bots/api#loginurl

Trying to implement this, but straightforward approach does not work:

$keyboard = new \TelegramBot\Api\Types\Inline\InlineKeyboardMarkup([
    [
        ['text' => "Test", 'login_url' => 'https://example.com']
    ]
]);

And there's seem to be no constructors for LoginUrl object either. So, how?

phpony commented 3 years ago

Welp, I've got it:

$keyboard = new \TelegramBot\Api\Types\Inline\InlineKeyboardMarkup([
    [
        ['text' => "Test", 'login_url' => ['url' => 'https://example.com', 'request_write_access' => true]]
    ]
]);

Can be closed now.