8

我正在设计一个电报机器人。我想显示一些链接,例如

1-wkpviana

2- 通过主机托管

当用户点击它时,打开

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

在浏览器中。我如何在 php 中创建它?我的部分代码是:

<?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);
?>
4

1 回答 1

10

您似乎正在尝试发送带有<a>标签的链接,这工作正常,但需要您使用parse_mode=html参数,如此处所述。

我相信它看起来有点像这样:

$URL = "https://api.telegram.org/bot".$Token."/sendMessage?chat_id=".$ChatID."&text=".$Text."&parse_mode=HTML&reply_markup=".json_encode($KB);
于 2017-01-17T15:49:36.413 回答