因业务需要,在提交工单后,需要第一时间通知管理员,故有了微信提醒需求。
微信推送服务接口因开发时间原因,不在自行搭建。这里我选择了 wxpusher 接口,非常方便。
文档在此:
http://wxpusher.zjiecode.com/docs/#/
以下为调用代码
$geturl="http://wxpusher.zjiecode.com/api/fun/wxuser";//获取订阅者的api
$pushapi="http://wxpusher.zjiecode.com/api/send/message";//推送渠道api
//$appToken="apitoken_xxxx";//:应用api
//先获取该应用已定阅的uid
$s = file_get_contents($geturl."?appToken=".$appToken);
$returnmsg = json_decode($s, true);
$useruidarray=array();
if($returnmsg['success']){
foreach ($returnmsg['data']['records'] as $kbb ){
array_push($useruidarray, $kbb['uid']);
}
$dataarry =json_encode(array("appToken"=>$appToken,
"content"=>$pushmsg,
"contentType"=>1,
"uids"=>$useruidarray,
//"topicIds"=>array(158)
//"url"=>"http://wxpusher.zjiecode.com"
));
$ddd= http_post_json($pushapi,$dataarry);
$tem = json_decode($ddd[1], true);
return $tem["success"];
}
else{
return false;
}
以上内容希望帮助到大家,很多PHPer在进阶的时候总会遇到一些问题和瓶颈,业务代码写多了没有方向感,不知道该从那里入手去提升,对此我整理了一些资料,包括但不限于:分布式架构、高可扩展、高性能、高并发、服务器性能调优、TP6,laravel,YII2,Redis,Swoole、Swoft、Kafka、Mysql优化、shell脚本、Docker、微服务、Nginx等多个知识点高级进阶干货需要的可以免费分享给大家,需要
PHP进阶架构师>>>视频、面试文档免费获取docs.qq.com或者关注咱们下面的专栏
PHP架构师之路zhuanlan.zhihu.com来源:https://www.cnblogs.com/Lbox/p/12586959.html