You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

40 lines
1001 B

  1. <?php
  2. /**
  3. * 默认接口服务类
  4. *
  5. * @author: dogstar <chanzonghuang@gmail.com> 2014-10-04
  6. */
  7. class Api_Default extends PhalApi_Api {
  8. public function getRules() {
  9. return array(
  10. '*' => array( //通用接口参数
  11. 'code' => array('name' => 'code', 'require' => true, 'min' => 4, 'max' => 4),
  12. ),
  13. 'index' => array( //指定接口参数
  14. 'username' => array('name' => 'username', 'default' => 'PHPer', ),
  15. ),
  16. );
  17. }
  18. /**
  19. * 默认接口服务
  20. * @return string title 标题
  21. * @return string content 内容
  22. * @return string version 版本,格式:X.X.X
  23. * @return int time 当前时间戳
  24. */
  25. public function index() {
  26. return array(
  27. 'title' => 'Hello World!',
  28. 'content' => T('Hi {name}, welcome to use PhalApi!', array('name' => $this->username)),
  29. 'version' => PHALAPI_VERSION,
  30. 'time' => $_SERVER['REQUEST_TIME'],
  31. );
  32. }
  33. }