The example of this article describes the micro-JS-SDK custom sharing function. Share to everyone for your reference, specific as follows:
Share out the content, can be modified by JSSDK.
1. Configure JSSDK
Wx_config.html
<?php
Import ("@.org.jssdk");
$JSSDK = new Jssdk (c (' Oauth_config.appid '), C (' Oauth_config.appsecret '));
$signPackage = $jssdk->getsignpackage ();
? >
<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 ', '
chooseimage
', ' Uploadimage '
]
});
</script>
2. Join share to friends, share to friends circle events
<script>//
micro-letter Jssdk Development
Wx.ready (function () {
//share to friend
Wx.onmenushareappmessage ({
title: ' { SH: $wxShare. Title} ',//Product name
desc: ' {sh: $wxShare. desc} ',//Shop name
Link: ' {sh: $wxShare. Link} ',//product purchase address
Imgurl: ' {sh: $wxShare. Imgurl} ',//Shared icon
fail:function (res) {
alert (json.stringify (res));
}
);
//share to the circle
of Friends Wx.onmenusharetimeline ({
title: ' {sh: $wxShare. Title} ',//Product name
Link: ' {sh:$ Wxshare.link} ',//product purchase address
Imgurl: ' {sh: $wxShare. Imgurl} ',//share icon
fail:function (res) {
alert ( Json.stringify (res))
;}}; </script>
3. Background access to Wxshare data
/**** access to micro-credit sharing data ****/
$shop _id = $this->_get (' shop_id ', ' intval ');
$wxShare [' title '] = $goodsData [' name '];
$wxShare [' desc '] = $store [' name '];
$wxShare [' Imgurl ']= $this->siteurl. $goodsData [' logoimg '];
$wxShare [' link '] = $this->siteurl.u (' Goods/info ', array (' ID ' => $goodsData [' id '], ' shop_id ' => $shop _id));
$this->assign (' Wxshare ', $wxShare);
The address here must be an absolute address. Otherwise, the relative address, the micro-letter is not recognized.
If not set, it will be the default title, the default logo, the default details.
When you set up an event, you share it with what you want.
4. I want to distribute the page, the source code
More readers interested in JavaScript-related content can view this site: "JavaScript in the JSON Operation tips Summary", "JavaScript switching effects and techniques summary", "JavaScript Search Algorithm Skills summary", " JavaScript animation effects and tips Summary, "JavaScript Error and debugging skills Summary", "JavaScript data structure and algorithm skills summary", "JavaScript traversal algorithm and Skills summary" and "JavaScript Mathematical operation Usage Summary"
I hope this article will help you with JavaScript programming.