如何实现PHP公众号开发中的用户微信消息提醒功能?
- 内容介绍
- 文章标签
- 相关推荐
本文共计306个文字,预计阅读时间需要2分钟。
最近的一个项目,当用户账户有资金变动或成员变化时,需要发送一条微信消息提醒。对于新注册的公众号,申请使用模板消息需要等待几天时间。
最近做的一个项目,当有用户有资金到账或者成员变动时需要给他发一条微信消息提示。针对这个,开始想使用模板消息,但是刚注册的公众号申请消息模板需要几天时间申请,在时间不足下选择了使用客服消息接口。
这里跳过网页授权和用户信息获取,请求接口的步骤,主要看获取access_token,发布客服消息,验证是否关注公众号等接口。
1. 获取access_token。
// 获取access_token
public function getAccessToken($weid) {
$appID = "wxfaddfdfdfd6cf6fc3569"; // 服务号appID
$appSecret = "071bebfdfdofdfd23687bf53d63a"; // 服务号appSerect
$url = "api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appID&secret=$appSecret";
$content = iapi.weixin.qq.com/cgi-bin/user/info?access_token=".$accessToken."&openid=".$userinfo['openid']."&lang=zh_CN";
$res = iapi.weixin.qq.com/cgi-bin/message/custom/send?access_token='.$accessToken;
$res = iwww.longshidata.com/pages/exchange.html】
本文共计306个文字,预计阅读时间需要2分钟。
最近的一个项目,当用户账户有资金变动或成员变化时,需要发送一条微信消息提醒。对于新注册的公众号,申请使用模板消息需要等待几天时间。
最近做的一个项目,当有用户有资金到账或者成员变动时需要给他发一条微信消息提示。针对这个,开始想使用模板消息,但是刚注册的公众号申请消息模板需要几天时间申请,在时间不足下选择了使用客服消息接口。
这里跳过网页授权和用户信息获取,请求接口的步骤,主要看获取access_token,发布客服消息,验证是否关注公众号等接口。
1. 获取access_token。
// 获取access_token
public function getAccessToken($weid) {
$appID = "wxfaddfdfdfd6cf6fc3569"; // 服务号appID
$appSecret = "071bebfdfdofdfd23687bf53d63a"; // 服务号appSerect
$url = "api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appID&secret=$appSecret";
$content = iapi.weixin.qq.com/cgi-bin/user/info?access_token=".$accessToken."&openid=".$userinfo['openid']."&lang=zh_CN";
$res = iapi.weixin.qq.com/cgi-bin/message/custom/send?access_token='.$accessToken;
$res = iwww.longshidata.com/pages/exchange.html】

