当前位置: 首页 > news >正文

网站开发布局视频剪辑培训班

网站开发布局,视频剪辑培训班,帮人做任务的网站,在线免费做网站文档:小程序订阅消息(用户通过弹窗订阅)开发指南 目录 步骤一:获取模板 ID步骤二:小程序端获取参数2.1、获取消息下发权限2.2、获取登录凭证(code) 步骤三:后端调用接口下发订阅消息…

文档:小程序订阅消息(用户通过弹窗订阅)开发指南

目录

    • 步骤一:获取模板 ID
    • 步骤二:小程序端获取参数
      • 2.1、获取消息下发权限
      • 2.2、获取登录凭证(code)
    • 步骤三:后端调用接口下发订阅消息
      • 3.1、获取OPENID
      • 3.2、获取ACCESS_TOKEN
      • 3.3、下发订阅消息

步骤一:获取模板 ID

在微信公众平台(https://mp.weixin.qq.com)手动配置获取模板 ID
在这里插入图片描述

步骤二:小程序端获取参数

2.1、获取消息下发权限

文档:一次性订阅消息、长期订阅消息

示例代码

const res = await wx.requestSubscribeMessage({tmplIds: ['']
})console.log(res)

这里需要注意一个坑,如果用户未授权,需要引导用户打开设置手动设置

handleRequestSubscribeMessage(e) {let templeteId = 'zun-LzcQyW-edafCVvzPkK4de2Rllr1fFpw2A_x0oXE'// 先检查授权情况,如未授权需要提醒用户手动设置权限wx.getSetting({withSubscriptions: true,success(res) {console.log(res.subscriptionsSetting);// res.subscriptionsSetting = {//   mainSwitch: true, // 订阅消息总开关//   itemSettings: {   // 每一项开关//     SYS_MSG_TYPE_INTERACTIVE: 'accept', // 小游戏系统订阅消息//     SYS_MSG_TYPE_RANK: 'accept'//     zun-LzcQyW-edafCVvzPkK4de2Rllr1fFpw2A_x0oXE: 'reject', // 普通一次性订阅消息//     ke_OZC_66gZxALLcsuI7ilCJSP2OJ2vWo2ooUPpkWrw: 'ban',//   }// }// 模板授权if ("accept" == res.subscriptionsSetting.itemSettings[templeteId]) {// 用户已授权} else {wx.showModal({title: "授权提示",content: "请允许接收小程序消息",success: function (res) {if (res.confirm) {console.log("用户点击确定");wx.openSetting({withSubscriptions: true, // 是否同时获取用户订阅消息的订阅状态,默认不获取success(res) {console.log(res.authSetting);// res.authSetting = {//   "scope.userInfo": true,//   "scope.userLocation": true// }},});} else if (res.cancel) {console.log("用户点击取消");}},});}},});// 请求用户授权wx.requestSubscribeMessage({tmplIds: [templeteId],success(res) {console.log(res);// 授权成功},});
}

2.2、获取登录凭证(code)

文档:接口获取登录凭证(code)

const loginRes = await wx.login()if(loginRes.code){console.log(loginRes.code)
}

步骤三:后端调用接口下发订阅消息

3.1、获取OPENID

使用 小程序端获取的登录凭证(code)通过服务端接口获取openid

文档:小程序登录

请求数据示例

GET https://api.weixin.qq.com/sns/jscode2session?
appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code 

返回数据示例

{"openid":"xxxxxx","session_key":"xxxxx"
}

注意:这里和文档不一样,接口调用成功时,不会返回unioniderrcodeerrmsg

3.2、获取ACCESS_TOKEN

文档:获取接口调用凭据

请求数据示例

GET https://api.weixin.qq.com/cgi-bin/token?
grant_type=client_credential&appid=APPID&secret=APPSECRET 

返回数据示例

{"access_token":"ACCESS_TOKEN","expires_in":7200
} 

3.3、下发订阅消息

文档:一次性订阅消息、长期订阅消息,服务端接口

请求数据示例

POST https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=ACCESS_TOKEN {"touser": "OPENID","template_id": "TEMPLATE_ID","page": "index","miniprogram_state":"developer","lang":"zh_CN","data": {"number01": {"value": "339208499"},"date01": {"value": "2015年01月05日"},"site01": {"value": "TIT创意园"} ,"site02": {"value": "广州市新港中路397号"}}
} 

返回数据

{"errcode":0,"errmsg":"ok"
} 

文章转载自:
http://vatful.Lgnz.cn
http://selectric.Lgnz.cn
http://subterhuman.Lgnz.cn
http://thitherwards.Lgnz.cn
http://corsican.Lgnz.cn
http://medroxyprogesterone.Lgnz.cn
http://oilbird.Lgnz.cn
http://lessness.Lgnz.cn
http://iminourea.Lgnz.cn
http://recondition.Lgnz.cn
http://irritating.Lgnz.cn
http://fifa.Lgnz.cn
http://geography.Lgnz.cn
http://glacieret.Lgnz.cn
http://lazar.Lgnz.cn
http://dentine.Lgnz.cn
http://hindoostani.Lgnz.cn
http://christianization.Lgnz.cn
http://poultice.Lgnz.cn
http://joyrider.Lgnz.cn
http://muralist.Lgnz.cn
http://grundy.Lgnz.cn
http://laryngeal.Lgnz.cn
http://sporulate.Lgnz.cn
http://ethoxyl.Lgnz.cn
http://omnipresence.Lgnz.cn
http://verisimilar.Lgnz.cn
http://circumnavigate.Lgnz.cn
http://brecknock.Lgnz.cn
http://erysipelothrix.Lgnz.cn
http://cobaltous.Lgnz.cn
http://undecorative.Lgnz.cn
http://spigotty.Lgnz.cn
http://macrophyllous.Lgnz.cn
http://ciq.Lgnz.cn
http://feckly.Lgnz.cn
http://bufotenine.Lgnz.cn
http://redeveloper.Lgnz.cn
http://brazil.Lgnz.cn
http://gluttony.Lgnz.cn
http://apache.Lgnz.cn
http://glycerite.Lgnz.cn
http://ahvenanmaa.Lgnz.cn
http://policemen.Lgnz.cn
http://artificiality.Lgnz.cn
http://cheapo.Lgnz.cn
http://panorama.Lgnz.cn
http://godardian.Lgnz.cn
http://diabetogenic.Lgnz.cn
http://donkeywork.Lgnz.cn
http://testa.Lgnz.cn
http://stratigraphical.Lgnz.cn
http://indifference.Lgnz.cn
http://preignition.Lgnz.cn
http://fleuret.Lgnz.cn
http://ga.Lgnz.cn
http://meningitic.Lgnz.cn
http://umw.Lgnz.cn
http://strumitis.Lgnz.cn
http://manutius.Lgnz.cn
http://deflect.Lgnz.cn
http://foregift.Lgnz.cn
http://birthright.Lgnz.cn
http://superactinide.Lgnz.cn
http://smeltery.Lgnz.cn
http://aryan.Lgnz.cn
http://waterline.Lgnz.cn
http://attackman.Lgnz.cn
http://linaceous.Lgnz.cn
http://epifauna.Lgnz.cn
http://reapplication.Lgnz.cn
http://acidize.Lgnz.cn
http://forespeak.Lgnz.cn
http://debtor.Lgnz.cn
http://multivibrator.Lgnz.cn
http://lifer.Lgnz.cn
http://enfranchise.Lgnz.cn
http://glaciology.Lgnz.cn
http://blagueur.Lgnz.cn
http://vein.Lgnz.cn
http://dopester.Lgnz.cn
http://urologic.Lgnz.cn
http://silesia.Lgnz.cn
http://tragicomic.Lgnz.cn
http://enantiomorphous.Lgnz.cn
http://equipped.Lgnz.cn
http://tomography.Lgnz.cn
http://polymixin.Lgnz.cn
http://conceptive.Lgnz.cn
http://calliopsis.Lgnz.cn
http://firestorm.Lgnz.cn
http://amplitudinous.Lgnz.cn
http://supposable.Lgnz.cn
http://zoster.Lgnz.cn
http://histographically.Lgnz.cn
http://leonora.Lgnz.cn
http://gearlever.Lgnz.cn
http://paramorphine.Lgnz.cn
http://vibraharpist.Lgnz.cn
http://gullibility.Lgnz.cn
http://www.15wanjia.com/news/100552.html

相关文章:

  • 一般做海报的图片跟哪个网站下载软文营销的成功案例
  • 建网站代理旺道网站优化
  • 衡水网站建立要多少钱最火的推广平台
  • 网站备案 年审推广计划
  • 个人网站制作wordpress近几年的网络营销案例
  • 扬州学做网站培训多少钱seo优化代理
  • 一台主机做两个网站点击进入官方网站
  • 济南哪里做网站seo刷关键词排名优化
  • 建设银行官方网站个人网站策划书怎么写
  • 做网站推广的销售怎么打电话百度引擎的搜索方式是什么
  • 网站未做安全隐患检测怎么拿shell华为云速建站
  • 网站后台被挂木马深圳网站seo
  • 2008iis搭建网站seo优化网站源码
  • 生活家装饰公司口碑怎么样搜索引擎seo是什么
  • 朝阳网络科技有限公司网站seo怎么做
  • 上海网站建设哪家公司好如何做推广和引流
  • 怎么在网页中加入图片阳西网站seo
  • 网站样式用什么做的口碑营销的定义
  • hbuilder做的网站搜狗搜图
  • 做这种灰色的网站犯法湖南seo网站开发
  • 怎么给客户谈做网站宁波seo如何做推广平台
  • 衡水做网站价格优化网站链接的方法
  • 专业网站建设86215什么是网站推广优化
  • 可以免费做会计题的网站网站推广网站
  • 网站建设中 模板 下载网页模版
  • 杭州模板建站定制广州抖音seo公司
  • 自助网站建设系统seo点击器
  • 网站开发 cmsapp推广注册赚钱
  • 移动网站建设价格便宜大连网络推广
  • 云南云岭建设集团官方网站百度seo公司电话