php 微信分享

1.引入jssdk wechat-php-jssdk.zip (其中两个json文件需要读写权限)

<?php
require_once "./jssdk.php";
$jssdk = new JSSDK("APPID", "APPSECRET");
$signPackage = $jssdk->GetSignPackage();
?>

2.js分享代码

<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
  wx.config({
    debug: false,
    appId: <?php echo $signPackage["appId"];?>,
    timestamp: <?php echo $signPackage["timestamp"];?>,
    nonceStr: <?php echo $signPackage["nonceStr"];?>,
    signature: <?php echo $signPackage["signature"];?>,
    jsApiList: [
        onMenuShareTimeline,
        onMenuShareAppMessage,
        onMenuShareQQ,
        onMenuShareWeibo,
      // 所有要调用的 API 都要加到这个列表中
    ]
  });
  var title = ;
  var desc = ;
  var link = ;
  var imgUrl = ;
  wx.ready(function () {
      wx.onMenuShareAppMessage({
          title: title,
          desc: desc,
          link: link,
          imgUrl: imgUrl
        });
      wx.onMenuShareTimeline({
          title: title,
          desc: desc,
          link: link,
          imgUrl: imgUrl
        });
      wx.onMenuShareQQ({
          title: title,
          desc: desc,
          link: link,
          imgUrl: imgUrl
        });
      wx.onMenuShareWeibo({
          title: title,
          desc: desc,
          link: link,
          imgUrl: imgUrl
        });
  });
</script>

微信JS-SDK说明文档:http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html

更多接口详情可参考:http://www.cnblogs.com/txw1958/p/weixin-js.html

微信JS SDK Demo

php 微信分享

上一篇:微信开发学习日记(七):开源微商城wemall


下一篇:【 微信API接口(全) - 微信支付/微信红包/微信卡券/微信小店/JSAPI】