wxxcyChajian.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * 微信小程序接口
  4. */
  5. class wxxcyChajian extends Chajian{
  6. protected function initChajian()
  7. {
  8. $this->wxxcy_url = getconfig('wxxcy_url'); //微信小程序地址
  9. if(getconfig('systype')=='dev')$this->wxxcy_url='http://localhost/app/xcy_hosh/';
  10. }
  11. /**
  12. * 发送订阅消息
  13. * $xcytype 类型入hetong
  14. * $mobile 接收人员手机号
  15. * $params 参数,多个|分开
  16. * $tplid 发给哪个模版用0,1,2,3等
  17. */
  18. public function subscribe($xcytype, $mobile, $params,$tplid='0',$path='')
  19. {
  20. if(!$this->wxxcy_url)return returnerror('wxxcy_url empty');
  21. $onr = m('wxxcyus')->getone("`xcytype`='$xcytype' and `mobile`='$mobile'");
  22. if(!$onr)return returnerror('no subscribe');
  23. $url = ''.$this->wxxcy_url.'api.php?m=weixin&a=subscribe&xcytype='.$xcytype.'';
  24. $data['mobile'] = $mobile;
  25. $data['params'] = $params;
  26. $data['tplid'] = $tplid;
  27. $data['path'] = $path;
  28. $result = c('curl')->postcurl($url, $data);
  29. if(!$result)return returnerror('api not data');
  30. if(substr($result,0,1)!='{')return returnerror('err:'.$result.'');
  31. return json_decode($result, true);
  32. }
  33. }
粤ICP备19079148号