BaseServer.class.php 642 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace Common\Server;
  3. /**
  4. * Description of ItemServer
  5. *
  6. */
  7. class BaseServer {
  8. public function __construct() {
  9. }
  10. public function apiSuccess($param) {
  11. $ret['code'] = API_SUCCESS;
  12. $ret['data'] = $param;
  13. header('Content-Type:application/json; charset=utf-8');
  14. return $this->jsonEncode($ret);
  15. }
  16. public function apiError($type, $msg,$param=array()) {
  17. $ret['code'] = $type;
  18. $ret['msg'] =trim($msg);
  19. $ret= array_merge($ret,$param);
  20. header('Content-Type:application/json; charset=utf-8');
  21. return $this->jsonEncode($ret);
  22. }
  23. }