# wx.miniapp.requestSubscribeMessage
Jump WeChat to get a one-time subscription
# Precautions before Access
- This ability dependsWeChat Open SDK , need to follow the guidelines in theWeChat Open PlatformCreate a mobile application account to complete the relevant initialization configuration, details can be viewedWeChat mobile application capability initialization guidelines
- In order to access the one-time subscription message authorization, you need to register a developer account in the WeChat open platform, have an approved mobile application, and obtain the corresponding message template. ID After that, the access process can begin. Access documents can be viewed here
# parameter
attribute | type | Default value | Required | Introductions |
---|---|---|---|---|
templateId | string | - | no | Subscription Message Template The ID will be obtained after the application is submitted to the WeChat open platform for review. The path to view the template id is: WeChat open platform - Mobile applications - Area of competence - One-time subscription message |
reserved | string | - | no | Used to maintain the status of requests and callbacks, authorizing them to be sent back to third parties as is. This parameter can be used to prevent csrf Attack (cross-site request forgery attack), it is recommended that the third party bring this parameter, can be set to a simple random number plus session For verification, the developer can fill in the a-zA-Z0-9 Of the parameter values, the maximum 128 Bytes, asked to do urlencode |
scene | number | - | no | Scene value |
success | function | no | Successful callback after getting | |
fail | function | no | Get a failed callback |
# JSAPI Examples of code
// Login
wx.miniapp.requestSubscribeMessage({
scene: 123,
reserved: 'hello',
templateId: 'aY74R-PsuU6c-IWTMNzyMstLJ0ZMrfn9nIpGLpkTBPs',
success(e) {
console.log(`requestSubscribeMessage success`, e)
},
fail(e) {
console.log(`requestSubscribeMessage fail`, e)
}
})