首页 > 微信分享到朋友圈接口

微信分享到朋友圈接口

微信分享到朋友圈接口遇到了问题,之前遇到的问题是“invalid domain”,查了好久发现是域名没有备案。现在一切都正常了,微信打开网页也显示"config ok",但是分享到朋友圈接口没有任何反应,求帮忙,代码如下:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />        
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="shortcut icon" href="/favicon.ico" />
    <meta name="keywords" content="码乐" />
    <meta name="description" content="码乐" />
    <title>幸运大抽奖</title>
    <link rel="stylesheet" href="__PUBLIC__/home/css/btp.css">
    <link rel="stylesheet" href="__PUBLIC__/home/css/common.css">
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/home/js/jquery.js"></script>
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/home/js/common.js"></script>
</head>
<body style="background:#252331;">
    <div class="container recharge">
        <div class="maxWidth400">           
            <div class="hongbaoT">促销易红包大派送</div>
            <div class="hongbao1 hongbao2">
                <div class="gx">
                    <div class="big">1元</div>
                    恭喜您获得红包
                    <button class="btn btn_primary" id="onMenuShareTimeline">分享红包</button>
                </div>
            </div>

            <div class='fx_div'>
                <p class="fx_head">促销易幸运大抽奖</p>
                <p class='fx_cont'>关注促销易微信公众号,话费、现金红包等你来拿</p>
                <p class='fx_a'><a class='fx_close' href='javascript:void(0);'>取消</a><a href='{:U('home/user/hongbao')}'>发送</a></p>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="__PUBLIC__/home/js/jweixin-1.0.0.js"></script>
    <script>
      // $(function(){
      //   $('#onMenuShareTimeline').click(function(){
      //     console.log('bbbbbbbbbbbbbb');
      //   });
      //     console.log('cccccccccccccccc');
      // });
      wx.config({
        debug: true,
        appId: '{$signPackage.appid}',
        timestamp: {$signPackage.timestamp},
        nonceStr: '{$signPackage.noncestr}',
        signature: '{$signPackage.signature}',
        jsApiList: [
            'checkJsApi',
            'onMenuShareTimeline',
            'onMenuShareAppMessage'
        ]
      });
      wx.ready(function(){
        document.querySelector('#onMenuShareTimeline').onclick = function(){
          console.log('aaaaaaaaa');
          wx.onMenuShareTimeline({
            title: '促销易幸运大抽奖', // 分享标题
            link: 'http://movie.douban.com/subject/25785114/', // 分享链接
            imgUrl: 'http://demo.open.weixin.qq.com/jssdk/images/p2166127561.jpg', // 分享图标
            success: function (res) { 
                console.log(res);
            },
            cancel: function () { 
                // 用户取消分享后执行的回调函数
            }
          });
        }
      });
    </script>
</body>
</html>

wx.config中配置项均正确,线上地址:http://weixin.cuxiaoyi.com.cn/home/lottery/envelopeSave,可以查看源代码或在微信中打开试下。
点击“分享红包”按钮,没有任何的反应,实在是不知道哪里错了,请大家帮帮忙~~


分享接口要认证号才有权限。

可以借用别人的,或者用你的测试号


要微信认证账号才有接口权限。。。以后会不会开放啊,还有菜单权限


开发者中心,申请开发者帐号测试


如果只是单纯的调用分享接口,可以继续使用以前的JS代码,如下:

javascipt
WeixinJSBridge.on('menu:share:timeline', function(argv) { WeixinJSBridge.invoke('shareTimeline', { "appid": '', "img_url": '', "img_width": "640", "img_height": "640", "link": '', "desc": '', "title": '' }, onShareComplete); });

赶紧试试吧。


签名和官方的一样、 URL也是通过location.href.split('#')[0]获取的。。 也是一直提示 config:invalid signature 公众号的JS接口安全域名也是配置OK,就是不行。。 求大神帮助、
测试地址:http://weixin.zhjckx.com/ApiWeiXin/JsSdk


请问楼主解决了问题了吗,我现在也要做一个分享,求指点啊!谢谢!


onMenuShareTimeline 是定义用户 点击微信浏览器右上角按钮-分享到朋友圈 的内容

分享红包的按钮那里写id="onMenuShareTimeline" 是没有用的,不会触发分享到朋友圈。
你只能是让这个按钮点击之后跳一个蒙层,提示用户点击右上角按钮,分享到朋友圈

【热门文章】
【热门文章】