how to create link in telegram bot

23,315

You seem to be attempting to send the links with the <a> tag, which works fine, but requires you to use the parse_mode=html parameter, as documented here.

I believe it would look a bit like this:

$URL = "https://api.telegram.org/bot".$Token."/sendMessage?chat_id=".$ChatID."&text=".$Text."&parse_mode=HTML&reply_markup=".json_encode($KB);
Share:
23,315
Yousef Rahimy Akhondzadeh
Author by

Yousef Rahimy Akhondzadeh

I was born in 21 March 1984 in Kerman, Iran.

Updated on January 18, 2020

Comments

  • Yousef Rahimy Akhondzadeh
    Yousef Rahimy Akhondzadeh over 4 years

    I am designing a telegram bot. I want to show some links e.g.

    1- wkpviana

    2- vianahosting

    that when user click it, open

    http://wkpviana.net 
    http://vianahosting.ir
    

    in browser. How I can create it in php? part of my code is:

    <?php
    ...
    $sLink = "";
    foreach($Links as $Row){
        $sLink .= "<a href='".$Row->link_url."'>".$Row->link_name."</a>";
    }
    $Text = $sLink;
    ...
    $URL = "https://api.telegram.org/bot".$Token."/sendMessage?chat_id=".$ChatID."&text=".$Text."&reply_markup=".json_encode($KB);
    file_get_contents($URL);
    ?>