E
E
eshanglar2020-04-18 22:39:09
PHP
eshanglar, 2020-04-18 22:39:09

How to add a button with a Telegram link?

Hello. I need to add one button-url to the message. How to do it?

function message_to_telegram($text)
{
    $ch = curl_init();
    curl_setopt_array(
        $ch,
        array(
            CURLOPT_URL => 'https://api.telegram.org/bot' . TELEGRAM_TOKEN . '/sendMessage',
            CURLOPT_POST => TRUE,
            CURLOPT_RETURNTRANSFER => TRUE,
            CURLOPT_TIMEOUT => 10,
            CURLOPT_POSTFIELDS => array(
                'chat_id' => TELEGRAM_CHATID,
                'text' => $text,
            ),
        )
    );
    curl_exec($ch);
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nozzy, 2020-04-19
@eshanglar

$keyboard = [
    'inline_keyboard' => [
        [
            "text": "Link",
            "url": "https://my_site"
        ]
    ]
];

...

CURLOPT_POSTFIELDS => array(
                'chat_id' => TELEGRAM_CHATID,
                'text' => $text,
               'reply_markup' => json_encode($keyboard);
            ),

...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question