reimplat.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. class reimplatModel extends Model
  3. {
  4. public function initReimplat(){}
  5. public $reimplat_purl;
  6. public $reimplat_cnum;
  7. public $reimplat_secret;
  8. public $reimplat_devnum;
  9. public $reimplat_huitoken;
  10. public function initModel()
  11. {
  12. $this->option = m('option');
  13. $this->reimplat_purl = $this->option->getval('reimplat_purl');
  14. $this->reimplat_cnum = $this->option->getval('reimplat_cnum');
  15. $this->reimplat_secret = $this->option->getval('reimplat_secret');
  16. $this->reimplat_devnum = $this->option->getval('reimplat_devnum');
  17. $this->reimplat_huitoken = $this->option->getval('reimplat_huitoken');
  18. if(getconfig('systype')=='dev')$this->reimplat_purl = 'http://localhost/app/rockreim/';
  19. $this->initReimplat();
  20. }
  21. public function gethkey()
  22. {
  23. $key = $this->reimplat_huitoken;
  24. if(isempt($key))$key = $this->reimplat_secret;
  25. if(isempt($key))$key = $this->reimplat_cnum;
  26. return md5($key);
  27. }
  28. //获取地址
  29. public function geturl($m, $a,$can=array())
  30. {
  31. $url = $this->reimplat_purl;
  32. if(!$url)return showreturn('','没设置REIM通信平台地址', 201);
  33. if(substr($url,0,4)!='http')$url = 'http://'.$url.'';
  34. if(substr($url,-1)!='/')$url.='/';
  35. $url.= 'api.php?m='.$m.'&a='.$a.'';
  36. $url.= '&cnum='.$this->reimplat_cnum.'';
  37. $url.= '&secret='.$this->reimplat_secret.'';
  38. foreach($can as $k=>$v)$url.='&'.$k.'='.$v.'';
  39. return $url;
  40. }
  41. public function recordchu($cont)
  42. {
  43. $data = array('code'=>201,'success'=>false,'msg'=>'出错,返回:'.htmlspecialchars($cont).'');
  44. if($cont!='' && substr($cont,0,1)=='{'){
  45. $data = json_decode($cont, true);
  46. }
  47. return $data;
  48. }
  49. }
粤ICP备19079148号