【问题标题】:how to send html text to telegram channel?如何将 html 文本发送到电报频道?
【发布时间】:2020-05-11 14:26:00
【问题描述】:

大家好,我已经搜索了所有网络,但没有找到任何解决我问题的方法。 我有一个小脚本,它在 php 中解析一个 json 文件并对其进行操作,结果生成一个过滤数组并将其发送到电报频道。 一切正常,但在电报频道中,文本格式错误。 \n 和 br 标签不支持并在我的频道中显示为文本。我希望在电报中的每个数据中都换行。 我应该怎么做才能在电报中的每条消息中制作一个好看的文本? 我想在电报中有这样的文字: 例子 : 第 1 行:你好世界 1。 第 2 行:你好世界 2。 第 3 行:你好世界 3。

但在频道中: 你好世界1.你好世界2.你好世界3。 函数 print_data_in_telegram($code,$flag){

$temp = filter_data_from_json($code);
$data = "";
for($i = 0 ; $i< count($temp) ; $i++){
    if($flag ==1 ){

        $data .= $temp[$i]['Symbol'] . '{left days:' . $temp[$i]['Date'] .'}'. '\n';

    }else{

        $data .= $temp[$i]['Symbol'] . 
        '{remain days :'.(60-$temp[$i]['Date'] ).'}\n';
    }
}
return $data;

}

【问题讨论】:

标签: php telegram


【解决方案1】:

请使用html编码文本 喜欢&amp;lt;h1&amp;gt;Hello&amp;lt;/h1&amp;gt; 点击链接了解更多 html 编码 https://www.w3schools.com/charsets/ref_html_entities_4.asp 希望这会对你有所帮助:)

【讨论】:

  • 我见过但是没有断线实体!!
  • 最后我已经解决了我的问题并为像我这样的人写了代码:“
    \n
    ”换行
猜你喜欢
  • 1970-01-01
  • 2016-07-18
  • 2018-02-08
  • 2020-08-12
  • 2017-07-31
  • 2019-03-31
  • 2018-10-05
  • 2021-06-11
  • 2019-01-16
相关资源
最近更新 更多