rockkefuChajian.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * 客服
  4. */
  5. class rockkefuChajian extends Chajian{
  6. public $openkey,$updatekel,$updatekey;
  7. protected function initChajian()
  8. {
  9. $url = getconfig('rockkefu_url');
  10. $urlb = getconfig('rockkefu_localurl');
  11. if($urlb)$url = $urlb;
  12. $this->openkey = getconfig('rockkefu_key');
  13. if(substr($url,-1)!='/')$url.='/';
  14. $this->updatekel = $url;
  15. $this->updatekey = $url.'api.php';
  16. }
  17. public function geturlstr($mod, $act, $can=array())
  18. {
  19. $url = $this->updatekey;
  20. $url.= '?m='.$mod.'&a='.$act.'';
  21. $url.= '&openkey='.md5($this->openkey).'';
  22. foreach($can as $k=>$v)$url.='&'.$k.'='.$v.'';
  23. return $url;
  24. }
  25. /**
  26. * get获取数据
  27. */
  28. public function getdata($mod, $act, $can=array())
  29. {
  30. $url = $this->geturlstr($mod, $act, $can);
  31. $cont = c('curl')->getcurl($url);
  32. if(!isempt($cont) && contain($cont, 'success')){
  33. $data = json_decode($cont, true);
  34. }else{
  35. $data = returnerror('无法访问,'.$cont.'');
  36. }
  37. return $data;
  38. }
  39. /**
  40. * post发送数据
  41. */
  42. public function postdata($mod, $act, $can=array(), $cans=array())
  43. {
  44. $url = $this->geturlstr($mod, $act, $cans);
  45. $cont = c('curl')->postcurl($url, $can);
  46. if(!isempt($cont) && contain($cont, 'success')){
  47. $data = json_decode($cont, true);
  48. }else{
  49. $data = returnerror('无法访问,'.$cont.'');
  50. }
  51. return $data;
  52. }
  53. }
粤ICP备19079148号