如何在电报机器人中制作单词链接? [英] how to make links for words in telegram bot?

查看:74
本文介绍了如何在电报机器人中制作单词链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为电报机器人中的单词制作一个网址.
使用此代码但它不起作用:

I wanted to make a url for the words in telegram bot.
Used this code but it doesn't work:

https://api.telegram.org/bot$botToken/sendMessage?chat_id=chat_id&text=<a href="url.com">the word</a>

如何为单词制作链接.当用户点击这个词时,他会转到url地址页面

how to make link for the words. when the user clicks on the word, he will go to the url adress page

推荐答案

你应该使用 parse_mode 参数:

$url = 'https://api.telegram.org/bot<BOT_TOKEN>/sendMessage';
$parameters = [
    'text'       => '<a href=\'url.com\'>word</a>',
    'chat_id'    => <chat_id>,
    'parse_mode' => 'HTML'
];

echo $url . '?' . http_build_query($parameters);

输出:

https://api.telegram.org/bot<BOT_TOKEN>/sendMessage?text=%3Ca+href%3D%27url.com%27%3Eword%3C%2Fa%3E&chat_id=<chat_id>&parse_mode=HTML

这篇关于如何在电报机器人中制作单词链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆