最新的微信JSSDK分享接口是不是有问题呀?还是我的代码哪里错了?怎么无法自定义分享内容。


代码是这样的:


 <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
    wx.config({
        debug: true,
        appId: "wx02d04c1b737190fe",
        timestamp: "1421290950",
        nonceStr: "DArR9zORKGhde7AS",
        signature: "ef1ffc35b7b1b3e22b65994edc2d1546a1016b0f",
        jsApiList: [
            'checkJsApi',
            'onMenuShareTimeline',
            'onMenuShareAppMessage',
            'onMenuShareQQ',
            'onMenuShareWeibo'
        ]
    });

    wx.ready(function () {
        wx.checkJsApi({
            jsApiList: [
                'onMenuShareTimeline',
            ]
        });

        wx.onMenuShareTimeline({
            title: '互联网之子',
            link: 'http://wx.vland.cc/mobile.php?act=module&rid=406&fromuser=oktsYuHivHXuzdsMeCbWyF7b14UU&name=hllihe&do=sharelihe&weid=7',
            imgUrl: 'http://wx.vland.cc/resource/attachment/images/7/2015/01/fl2Lk2p5o3iOJP3jdp9iPXI9i93iPm.jpg',
            trigger: function (res) {
                alert('用户点击分享到朋友圈');
            },
            success: function (res) {
                alert('已分享');
            },
            cancel: function (res) {
                alert('已取消');
            },
            fail: function (res) {
                alert('wx.onMenuShareTimeline:fail: '+JSON.stringify(res));
            }
        });
    });
    wx.error(function (res) {
        alert('wx.error: '+JSON.stringify(res));
    });
</script>

因为打开了调试模式,弹出调试信息 说明配置没问题:
弹出调试信息

又弹出了checkJsApi,说明客户端支持这个接口:
checkJsApi

然后就没有别的弹出了……

分享到朋友圈:
标题还是那个标题,并没有变成自定义的“ 互联网之子 ”,这是为什么?
分享到朋友圈

微信开发 微信分享代码 html5 微信公众平台 JavaScript

真無口鬼畜執事 10 years, 10 months ago

因为现在只有特定域名能分享,一个公众号对应一个域名,需要备案。

大型食肉动物 answered 10 years, 10 months ago

请问下timestamp 和nonceStr这2个参数应该怎么填写,是要在公众号里配置吗?还有官方文档上说JS接口安全域名”。 是什么意思 应该怎么填写

Warden answered 10 years, 10 months ago

wx.onMenuShareTimeline({
title: '互联网之子',
link: ' http://wx.vland.cc/mobile.php?act=module&rid=406&fromuser=oktsYuHivHXuzdsMeCbWyF7b14UU&name=hllihe&do=sharelihe&weid=7 ',
imgUrl: ' http://wx.vland.cc/resource/attachment/images/7/2015/01/fl2Lk2p5o3iOJP3jdp9iPXI9i93iPm.jpg ',
trigger: function (res) {
alert('用户点击分享到朋友圈');
},
success: function (res) {
alert('已分享');
},
cancel: function (res) {
alert('已取消');
},
fail: function (res) {
alert('wx.onMenuShareTimeline:fail: '+JSON.stringify(res));
}
});
你可以绑定到一个按钮点击事件上面,或者和上面说的一样 延迟加载

Suchman answered 10 years, 10 months ago

和楼主的代码一样,微信服务器已经认证。分享的时候显示的只是网页的标题,并不是设置好的个性化分享内容。求指导

JOHN十花 answered 10 years, 10 months ago

确保你的公众号是有认证的,不然是没办法使用的

草泥马大爷驾到 answered 10 years, 10 months ago

貌似跟微信版本有关系,升级最新版再试试

很神秘的神秘人 answered 10 years, 10 months ago


 wx.onMenuShareTimeline({
            title: '互联网之子',
            link: 'http://wx.vland.cc/mobile.php?act=module&rid=406&fromuser=oktsYuHivHXuzdsMeCbWyF7b14UU&name=hllihe&do=sharelihe&weid=7',
            imgUrl: 'http://wx.vland.cc/resource/attachment/images/7/2015/01/fl2Lk2p5o3iOJP3jdp9iPXI9i93iPm.jpg',
            trigger: function (res) {
                alert('用户点击分享到朋友圈');
            },
            success: function (res) {
                alert('已分享');
            },
            cancel: function (res) {
                alert('已取消');
            },
            fail: function (res) {
                alert('wx.onMenuShareTimeline:fail: '+JSON.stringify(res));
            }
        });

把这段代码,封装成个函数,然后用settimeout延迟2秒加载试试。

假面兔子先生 answered 10 years, 10 months ago

额我也没看出神马问题……

sosyuki answered 10 years, 10 months ago

你的公众号认证了吗? 认证需要Money哦。。
没有认证是不让用自定义分享内容的哦。

MoeOta answered 10 years, 10 months ago

我也觉得有问题,遇到同样的情况,其它比如录音接口,定位接口都正常,就是分享接口不能使用,checkApi校验显示正常,但是就是不能自定义分享内容,应该是微信官方的问题

=================
发现问题了,必须是认证账号才能定制分享
图片描述

Reborn伪 answered 10 years, 10 months ago

Your Answer