收藏
回答

How can I use wechat url?

When I want to use the url image of wechat in my system. But it shows an error message on wechat. How can I fix it?

API: https://api.weixin.qq.com/cgi-bin/draft/add?access_token=ACCESS_TOKEN

{
    "articles": [
        {
            "title":TITLE,
            "author":AUTHOR,
            "digest":DIGEST,
            "content":<img src='https://mmbiz.qpic.cn/mmbiz_jpg/6Qq7RC4pviaR1BBwG4yrhWrIy8PTJo2Qib5Mib5QAmBLR8mrgmFt55eicnqaXxicfKoGhLWnKaF8Tgdib5ibC4TcrgBtQ/640?wx_fmt=jpeg'>,  <<---------
            "content_source_url":CONTENT_SOURCE_URL,
            "thumb_media_id":THUMB_MEDIA_ID,
            "need_open_comment":0,
            "only_fans_can_comment":0
        }
        //若新增的是多图文素材,则此处应还有几段articles结构
    ]
}


url image : https://mmbiz.qpic.cn/mmbiz_jpg/6Qq7RC4pviaR1BBwG4yrhWrIy8PTJo2Qib5Mib5QAmBLR8mrgmFt55eicnqaXxicfKoGhLWnKaF8Tgdib5ibC4TcrgBtQ/640?wx_fmt=jpeg

最后一次编辑于  2023-09-14
回答关注问题邀请回答
收藏

1 个回答

  • 哄哄
    哄哄
    发表于移动端
    2023-09-14
    This is the anti-hotlink mechanism of WeChat picture bed. The pictures uploaded by the WeChat system will be checked by referer when visiting, and if they do not belong to the WeChat whitelist list, the pictures cannot be displayed correctly. Not recommended to use WeChat as a picture bed to display on your website
    2023-09-14
    有用
    回复 2
    • Chalisa.N
      Chalisa.N
      2023-09-14
      If I really want to use the url image of wechat, because of this api, if using an external url image, it cannot be displayed. Do you have any suggestions for me?
      2023-09-14
      回复
    • 哄哄
      哄哄
      发表于移动端
      2023-09-15回复Chalisa.N
      If you must use the WeChat API to upload images and display them correctly on your own website, here are a few things you can try. 1. Configure the referrerpolicy attribute in the img tag, the value is no-referrer. 2. Use the server to transfer the proxy image, or use the server to forward it, which requires you to configure the correspondence between the WeChat image link and your own resolution of the link. 3. Since anti-hotlinking is mainly identified with referer homology on the WeChat server, you can use some whitelist methods, such as iframe operations, or browser plugins to achieve confusion. You can choose your way, I suggest you choose the first one. If you use a server proxy, you need to automatically parse and convert the image address in the frontend, such as the WeChat address is https://mmbiz.qpic.cn/xxxxx. You can change it to https://your.server/mmbiz.qpic.cn/xxxxx, and then your.server represents your own server address, proxies and resolves according to the content that follows
      2023-09-15
      回复
登录 后发表内容