首頁  >  文章  >  微信小程式  >  微信開發 分享朋友圈或好友程式碼

微信開發 分享朋友圈或好友程式碼

黄舟
黄舟原創
2016-12-30 10:33:312492瀏覽

<script type="text/javascript">

document.addEventListener(&#39;WeixinJSBridgeReady&#39;, function onBridgeReady() {

window.shareData = {

"imgUrl": "__APP__/images/jp_1.jpg",

"timeLineLink": "http://dc.exweixin.com/index.php?app=RedPacket&mod=Index&act=robSmallRed&fatherid={$fatherid}",//好友

"sendFriendLink": "http://dc.exweixin.com/index.php?app=RedPacket&mod=Index&act=robSmallRed&fatherid={$fatherid}",//朋友圈

"weiboLink": "",

"tTitle": "标题!",

"tContent": "内容",

"fTitle": "!",

"fContent": "!",

"wContent": ""

};

// 发送给好友

WeixinJSBridge.on(&#39;menu:share:appmessage&#39;, function (argv) {

WeixinJSBridge.invoke(&#39;sendAppMessage&#39;, {

"img_url": window.shareData.imgUrl,

"img_width": "640",

"img_height": "640",

"link": window.shareData.sendFriendLink,

"desc": window.shareData.fContent,

"title": window.shareData.fTitle

}, function (res) {

_report(&#39;send_msg&#39;, res.err_msg);

})

});

// 分享到朋友圈

WeixinJSBridge.on(&#39;menu:share:timeline&#39;, function (argv) {

WeixinJSBridge.invoke(&#39;shareTimeline&#39;, {

"img_url": window.shareData.imgUrl,

"img_width": "640",

"img_height": "640",

"link": window.shareData.timeLineLink,

"desc": window.shareData.tContent,

"title": window.shareData.tTitle

}, function (res) {

_report(&#39;timeline&#39;, res.err_msg);

});

});

// 分享到微博

WeixinJSBridge.on(&#39;menu:share:weibo&#39;, function (argv) {

WeixinJSBridge.invoke(&#39;shareWeibo&#39;, {

"content": window.shareData.wContent,

"url": window.shareData.weiboLink,

}, function (res) {

_report(&#39;weibo&#39;, res.err_msg);

});

});

}, false)

</script>

 以上就是微信開發 分享朋友圈或好友代碼的內容,更多相關內容請關注PHP中文網(www.php.cn)!


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn