微信分享,如何更改再分享描述和缩略图? [英] WeChat sharing, how to change re-share description and thumbnail?

查看:336
本文介绍了微信分享,如何更改再分享描述和缩略图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题

是否可以在微信中共享我的网站页面时提供自定义标题,描述和缩略图?

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

背景

我们有一个iPhone应用程序,用户可以从该应用程序使用微信(又名微信)与朋友发布/共享帖子.

We have an iPhone app from which users can publish/share posts with their friends using WeChat (aka Weixin).

从应用程序共享标题时,将通过API为共享页面发布说明和图像(从应用程序共享时,这些显示和图像会根据需要显示).分享后,朋友们可以在微信(而不是我们的应用程序)中打开这些页面.

When sharing from the app a title, a description and an image are posted via the API for the shared page (these display as desired when shared from the app). Once shared the friends open these pages in WeChat (and not our app).

问题是,当朋友使用微信自己的共享按钮重新共享我们的页面时,它会丢失我们提供的描述.它将与HTML标题标签,页面上的第一张图像(被拉伸或压缩为正方形缩略图)以及原始描述所在的位置重新共享,仅显示页面的URL.

The problem is that when the friends re-share our pages using WeChat's own share button it loses the description we provided. It will re-share with the HTML title tag, the first image on the page (stretched or squished to a square thumbnail) and where the description was originally it just shows the URL of the page.

我尝试在description meta标记中提供说明,但是很遗憾.我什至尝试了Facebook样式/开放图og:description meta标签.

I have tried providing descriptions in a description meta tag but to no luck. I have even tried Facebook style/open graph og:description meta tags.

边注

我在一个似乎克服了这个问题的中文站点上浏览了源代码.我认为可以使用名为WeixinJSBridge的javascript插件解决.不幸的是,我一直无法找到任何英文文档-我的中文不好,而且我的意思不是很清楚.

I have looked through the source on a Chinese site that seems to have overcome this issue. I think it's solved using a javascript plugin of some sort called WeixinJSBridge. Unfortunately I have been unable to uncover any documentation in English - My Chinese isn't great, and by not great I mean, I can't read a word.

推荐答案

[自微信发布新的JS SDK以来不起作用]这是微信的解决方案形式:

[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);

这篇关于微信分享,如何更改再分享描述和缩略图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆