本文实例为大家分享了php微信分享到朋友圈、QQ、朋友、微博的具体代码,供大家参考,具体内容如下
前台代码
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script>
wx.config({
debug: false,
appId: "{$signPackage['appId']}",
timestamp: "{$signPackage['timestamp']}",
nonceStr: "{$signPackage['nonceStr']}",
signature: "{$signPackage['signature']}",
jsApiList: [
'onMenuShareAppMessage',
'onMenuShareTimeline',
'onMenuShareQQ',
'onMenuShareWeibo',
]
});
wx.ready(function () {
var shareData = {
title: `{$info.ma_title}`,
desc: `{$info.briefcontent}`,
link: '',
imgUrl: `{$info['activity_pic']}`,
trigger: function (res) {
alert('用户点击发送给朋友');
},
success: function (res) {
alert('已分享');
},
cancel: function (res) {
alert('已取消');
},
fail: function (res) {
alert(JSON.stringify(res));
}
}
wx.onMenuShareAppMessage(shareData);
wx.onMenuShareTimeline(shareData);
wx.onMenuShareQQ(shareData);
wx.onMenuShareWeibo(shareData);
});
</script>
后台代码
jssdk.php获取地址
require_once VENDOR_PATH."jssdk/jssdk.php";
//WX_APPID和WX_APP_SECRET填写自己的即可
$jssdk = new \JSSDK(C("WX_APPID"),C("WX_APP_SECRET"));
$signPackage = $jssdk->getSignPackage();
$this->assign('signPackage',$signPackage);
您可能感兴趣的文章:微信JSSDK分享功能图文实例详解微信二次分享报错invalid signature问题及解决方法微信小程序生成分享海报方法(附带二维码生成)php实现微信分享朋友链接功能微信小程序实现的自定义分享功能示例微信分享的标题、缩略图、连接及描述设置方法微信支付终于成功了(安卓、iOS)在此分享PHP开发微信支付的代码分享基于js实现微信发送好友如何分享到朋友圈、微博微信公众平台开发教程②微信端分享功能图文详解