免费调用微信推送接口

注册测试公众号

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

扫码开通后,将会出现后台页面,拿到这四个值

  • appID

  • appsecret

  • 接受消息者,扫码拿到 openId ,也就是接受者的id号

  • template_id

    模板内容固定格式,演示的content是将要推送消息的key

推送消息

第一步,拿到临时推送授权token

GET

https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={appId}&secret={appsecret}

第二步,开始推送

POST application/json

https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={access_token}
{
    "touser": "{openId}",
    "template_id": "{template_id}",
    "url": "https://weixin.qq.com",
    "data":{
        "content":{
            "value":"这里是提醒的内容"
        }
    }
}

posted @ 2024-06-20 20:23  trykle  阅读(9)  评论(0编辑  收藏  举报