微信分享到朋友圈接口
微信分享到朋友圈接口遇到了问题,之前遇到的问题是“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
,可以查看源代码或在微信中打开试下。
点击“分享红包”按钮,没有任何的反应,实在是不知道哪里错了,请大家帮帮忙~~
猫猫猪OTL
9 years, 9 months ago
Answers
如果只是单纯的调用分享接口,可以继续使用以前的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); });
赶紧试试吧。
kyokani
answered 9 years, 9 months ago