WeChat public account sharing function anti-pit guide

Posted May 27, 20202 min read

  1. The linked domain name to be shared must be the same as the business domain name configured on the WeChat public account background. Note that the business domain name configured on the WeChat public account cannot have a port number, otherwise the sharing is unsuccessful, and the WeChat applet does not have this restriction.

  2. You need to add the sharing interface that will be abandoned to make it compatible, otherwise the sharing will also be invalid.

    wx.config({
    debug:false,
    appId:appId,
    timestamp:timestamp,
    nonceStr:nonceStr,
    signature:signature,
    jsApiList:[
    "updateTimelineShareData",
    "updateAppMessageShareData",
    "onMenuShareAppMessage",
    "onMenuShareTimeline"
    ]
    })
    if(wx.updateAppMessageShareData) {
    Wx.updateAppMessageShareData({
    Title:title, //share title
    Desc:desc, //share description
    Link:link, //share link, the link domain name or path must be the same as the public number JS security domain name corresponding to the current page
    ImgUrl:imgUrl, //share icon
    Success:function() {}
    });
    } else {
    Wx.onMenuShareAppMessage({
    Title:title, //share title
    Desc:desc, //share description
    Link:link, //share link, the link domain name or path must be the same as the public number JS security domain name corresponding to the current page
    ImgUrl:imgUrl, //share icon
    Type:"link", //Share type, music, video or link, if not filled, the default is link
    DataUrl:"", //If the type is music or video, you need to provide a data link, the default is empty
    Success:function() {
    Callback function executed after the user clicks the share
    }}
    });
    }
    if(wx.updateTimelineShareData) {
    Wx.updateTimelineShareData({
    Title:title, //share title
    Link:link, //share link, the link domain name or path must be the same as the public number JS security domain name corresponding to the current page
    ImgUrl:imgUrl, //share icon
    Success:function() {}
    });
    } else {
    Wx.onMenuShareTimeline({
    Title:title, //share title
    Link:link, //share link, the link domain name or path must be the same as the public number JS security domain name corresponding to the current page
    ImgUrl:imgUrl, //share icon
    Success:function() {
    Callback function executed after the user clicks the share
    }}
    });
    }
    Wx.error(err => {
    Toast("Authentication failed, please quit and try again");
    });

Related Posts