微信公众号开发(服务号)消息推送-测试账号版

说明:有正式版和测试版本 ,正式版需要企业微信认证资质300r ,测试版不需要。

​ 仅演示测试版本 ,认证版自行搜。

接入文档:https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Get_access_token.html

大致流程:
获取token,用token进行推送 推送的时候需要指定openid和模板消息 。


如上校验地址可配可不配(只做推送不需要),该地址后期可用来接收【用户给公众号】发的消息,然后post到这个地址自己接收做额外diy开发


微信公众号开发(服务号)消息推送-测试账号版

一、进入【微信公众账号测试号申请系统】

https://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login

二、获取 Access token

https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Get_access_token.html
curl --request GET \
  --url 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx59855554adf27f8ce8b&secret=fb812967555492e3a9a429c6a85d38ddf54' \
  --header 'Accept: */*' \
  --header 'Accept-Encoding: gzip, deflate, br' \
  --header 'Connection: keep-alive' \
  --header 'User-Agent: PostmanRuntime-ApipostRuntime/1.1.0'
  • curl如上,贴上自己的appid和secret即可

三、推送msg

https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html#%E5%8F%91%E9%80%81%E6%A8%A1%E6%9D%BF%E6%B6%88%E6%81%AF
curl --request POST \
  --url 'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=90_UMBjdcK5mbogthDdTImx7KdgoDHloQud-7zQbGp6AKrMHCQ-iTi7dT-z6muiQp60ALP2WXrTT9SvliGMT4P6BY5z68i469OZDzm5FkFbNKL8eKhbUoEHW17hmHsLZMjADAESF' \
  --header 'Accept: */*' \
  --header 'Accept-Encoding: gzip, deflate, br' \
  --header 'Connection: keep-alive' \
  --header 'Content-Type: application/json' \
  --header 'User-Agent: PostmanRuntime-ApipostRuntime/1.1.0' \
  --data '      {
           "touser":"ozRaZ6hB7ZhCtZNekIKyQl-y_8nQ",
           "template_id":"ckOUhUDYllkzPfjLclhQ73xwTvMoaC__Of3yTNwCNXs",
           "url":"http://weixin.qq.com/download",  
            "client_msg_id":"MSG_000001",
           "data":{

                   "keyword1":{
                       "value":"巧克力"
                   },
                   "keyword2": {
                       "value":"39.8元"
                   },
                   "keyword3": {
                       "value":"2014年9月22日"
                   }
           }
       }'
  • curl如上,贴上自己的token、openid、tempid

踩坑指南:

是基础消息下的【模板消息接口】===>发送模板消息 ,而不是订阅通知下的【订阅通知接口!!】

获取用户发送的消息接口文档

https://developers.weixin.qq.com/doc/service/guide/product/message/Receiving_standard_messages.html

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值