公众号发送文本消息跳转到小程序卡片 a标签尖括号会被转义,已影响正常运营
发布于 4 年前 作者 qiang75 15698 次浏览 来自 问答

 当前 Bug 的表现(可附上截图)

   

- 预期表现

{

    "touser": "ovGr-jmcHzFtZemn_yQme891ksrA",

    "msgtype": "text",

    "text": {

        "content": "<a href=\"http://m.huajialishe.com\" data-miniprogram-appid=\"wx64b88b7deae66cee\" data-miniprogram-path=\"pages/index/index\">点击跳小程序</a>"

    }

}

- 复现路径

https://mp.weixin.qq.com/debug?token=374098845&lang=zh_CN  我用官方测试的都给我直接转义了

- 提供一个最简复现 Demo

有很多公众号都可以文本带链接的。

3 回复

大兄弟,你不测试吗?

这个问题好解决的,你通过客服消息发小程序,把content,urlencode一下在发送就好了。

        $content = $this->message['content'];
        $text = "<a href='http://www.qq.com' data-miniprogram-appid='wxa8a4d4XXXXXX' data-miniprogram-path='pages/index/index'>礼品卡,你送礼,我帮你</a>";
        $custom = array(
            'msgtype' => 'text',
            'text' => array('content' => urlencode($text)),
            'touser' => $this->message['from'],
        );
        $account_api = WeAccount::create();
        $result = $account_api->sendCustomNotice($custom);

__
__

效果如下:

__
__

解决了你的问题,记得点赞关注一下!

这个不是bug吧,官方有说过可以这么用吗?

回到顶部