WechatMp.php 1018 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace app\api\controller\hprose;
  3. use app\api\controller\hprose\util\WechatMpHelper;
  4. use app\common\model\WechatConfig;
  5. use EasyWeChat\Factory;
  6. use think\facade\Log;
  7. class WechatMp
  8. {
  9. /**
  10. * 发送1条模板消息
  11. * @param $authInfo,数组,索引值为:code ,time,sign
  12. * @param $data ,数组,每个元素为1条模板消息
  13. * @throws \think\db\exception\DataNotFoundException
  14. * @throws \think\db\exception\DbException
  15. * @throws \think\db\exception\ModelNotFoundException
  16. */
  17. public function templateMessageSend($authInfo, $data)
  18. {
  19. Log::record("接收参数:authInfo:" . json_encode($authInfo, JSON_UNESCAPED_UNICODE));
  20. Log::record("接收参数:data:" . json_encode($data, JSON_UNESCAPED_UNICODE));
  21. $wechatMpHelper = new WechatMpHelper($authInfo);
  22. if ($wechatMpHelper->res["code"] != 0) {
  23. return $wechatMpHelper->res["code"];
  24. }
  25. return $wechatMpHelper->templateMessageSend($data);
  26. }
  27. }