Points gifting rules can be set in the background to encourage users to forward mini programs to WeChat groups, and then reward points to users to help promote mini programs.

The backend needs to configure the points gift rules first, and set how many points rewards users can get every time they forward to a WeChat group; at the same time, it is necessary to set up the gift online for the day to prevent users from cheating by swiping points.After a user forwards a mini program to a WeChat group, the information of the WeChat group cannot be immediately sensed and read. The group information can only be read from the group when a user in the group clicks to open the mini program. Therefore, the gift points will also require users in the group to click to trigger (that is, if it is forwarded to a group and no one in the group clicks to open the mini program, the system will still consider it not forwarded)
**! ! ! In the same WeChat group and on the same day, the system will only issue rewards once! ! !**
#Open ShareTicket
[https://developers.weixin.qq.com/miniprogram/dev/api/share/wx.showShareMenu.html](https://developers.weixin.qq.com/miniprogram/dev/api/share/wx.showShareMenu.html)
In the onLoad method in the js file of the forwarding page, declare:
```javascript
wx.showShareMenu({
withShareTicket: true
})
```
_In the forwarding link, please bring the uid of the forwarder. Subsequent points rewards will be issued directly to the user of this uid. Therefore, if you do not bring uid data, then you will not know who forwarded this forwarding in the following steps_
# Click to trigger
**In the onLaunch or onShow method of the app.js file**, we write this:
```javascript
if (e.shareTicket) {
wx.getShareInfo({
shareTicket: e.shareTicket,
success: res => {
console.log(res)
console.log({
referrer: e.query.inviter_id,
encryptedData: res.encryptedData,
iv: res.iv
})
wx.login({
success (loginRes) {
if (loginRes.code) {
WXAPI.shareGroupGetScore(
loginRes.code,
e.query.inviter_id,
res.encryptedData,
res.iv
).then(_res => {
console.log(_res)
}).catch(err=>{
console.error(err)
})
} else {
console.error('Login failed!' + loginRes.errMsg)
}
}
})
}
})
}
```
#SDK guide
```javascript
WXAPI.shareGroupGetScore(code, referrer, encryptedData, iv)
```
+ code Current user’s login credentials
+ Referrer is the user number of the user who forwarded it to the WeChat group. The system will issue the bonus points to this user.
+ encryptedData** **_Mini program api:wx.getShareInfo obtained_
+ iv applet api:wx.getShareInfo obtained
For details, please see WeChat official documentation:
[https://developers.weixin.qq.com/miniprogram/dev/api/share/wx.getShareInfo.html#%E7%A4%BA%E4%BE%8B%E4%BB%A3%E7%A0%81] (https://developers.weixin.qq.com/miniprogram/dev/api/share/wx.getShareInfo.html#%E7%A4%BA%E4%BE%8B%E4%BB%A3%E7%A0%81)
The interface returns:
```json
{
code: 0,
msg: 'success',
data: 'openGId'
}
```
After the interface is successful, the WeChat group ID will be returned.