WeChat sharing, how to change re-share description and thumbnail?

前端 未结 2 1151
别那么骄傲
别那么骄傲 2020-12-31 22:46

Question

Is there a way to provide a custom title, description and thumbnail for when my website pages are shared from within WeChat?

相关标签:
2条回答
  • 2020-12-31 23:34

    Actually right now WeChat does provide iOS/Andriod SDK for share content in Moments or with friend, and here is the English documentation for that: http://dev.wechat.com/wechatapi/messages-moments

    0 讨论(0)
  • 2020-12-31 23:47

    [Not working since WeChat published the new JS SDK] This is solution form WeChat: http://mp.weixin.qq.com/qa/index.php?qa=3163 However, there are all Chinese. The code you could try is below:

    
    var imgUrl = 'http://xxx/your-share-icon.png';
    var lineLink = 'http://xxx/your-share-link';
    var descContent = "your-content-desc";
    var shareTitle = 'you-share-title';
    var appid = 'your-app-id (from WeChat)';
    
    function shareFriend() {
        WeixinJSBridge.invoke('sendAppMessage',{
                                "appid": appid,
                                "img_url": imgUrl,
                                "img_width": "640",
                                "img_height": "640",
                                "link": lineLink,
                                "desc": descContent,
                                "title": shareTitle
                                }, function(res) {
                                _report('send_msg', res.err_msg);
                                })
    }
    function shareTimeline() {
        WeixinJSBridge.invoke('shareTimeline',{
                                "img_url": imgUrl,
                                "img_width": "640",
                                "img_height": "640",
                                "link": lineLink,
                                "desc": descContent,
                                "title": shareTitle
                                }, function(res) {
                                _report('timeline', res.err_msg);
                                });
    }
    function shareWeibo() {
        WeixinJSBridge.invoke('shareWeibo',{
                                "content": descContent,
                                "url": lineLink,
                                }, function(res) {
                                _report('weibo', res.err_msg);
                                });
    }
    // WeChat browser will initial by above function and trigger WeixinJSBridgeReady event.
    document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
    
            // share to friend
            WeixinJSBridge.on('menu:share:appmessage', function(argv){
                shareFriend();
                });
    
            // share to timeline
            WeixinJSBridge.on('menu:share:timeline', function(argv){
                shareTimeline();
                });
    
            // share to weibo
            WeixinJSBridge.on('menu:share:weibo', function(argv){
                shareWeibo();
                });
            }, false);
    
    
    0 讨论(0)
提交回复
热议问题