YcApiHprose.php 964 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace app\common\util;
  3. use Hprose\Http\Client;
  4. class YcApiHprose
  5. {
  6. protected $client;
  7. protected $wechatCode ="rmkj_mp";
  8. protected $wechatSignKey = "123456";
  9. public function __construct()
  10. {
  11. $this->wechatCode= env("app.wechat_code");
  12. $this->wechatSignKey= env("app.wechat_sign_key");
  13. $url = env("app.hprose_api");// "http://api.ycxxkj.com/index.php/api/WechatHprose/server";
  14. $this->client = Client::create($url, false);
  15. }
  16. protected function getAuthParam()
  17. {
  18. $auth = [];
  19. $auth["time"] = time();
  20. $auth["code"] = $this->wechatCode;
  21. $auth["sign"] = strtoupper(md5($auth["code"] . $auth["time"] . $this->wechatSignKey));
  22. return $auth;
  23. }
  24. /**
  25. * 发送模板消息
  26. */
  27. public function templateMessageSend($data)
  28. {
  29. $res = $this->client->templateMessageSend($this->getAuthParam(), $data);
  30. return $res;
  31. }
  32. }