2 files added
5 files modified
New file |
| | |
| | | <?php |
| | | |
| | | class MyRequest extends PhalApi_Request{ |
| | | public function __construct($data = NULL) { |
| | | parent::__construct($data); |
| | | |
| | | // json处理 |
| | | $this->post = file_get_contents('php://input'); |
| | | |
| | | // 普通xml处理 |
| | | //$this->post = simplexml_load_string ( |
| | | // file_get_contents('php://input'), |
| | | // 'SimpleXMLElement', |
| | | // LIBXML_NOCDATA |
| | | //); |
| | | //$this->post = json_decode(json_encode($this->post), TRUE); |
| | | } |
| | | } |
| | | |
| | |
| | | protected function loadClass($path, $className) { |
| | | $toRequireFile = $path . DIRECTORY_SEPARATOR |
| | | . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; |
| | | |
| | | if (file_exists($toRequireFile)) { |
| | | require_once $toRequireFile; |
| | | return TRUE; |
| | |
| | | * @var string 接口服务方法名 |
| | | */ |
| | | protected $actionName; |
| | | |
| | | |
| | | /** |
| | | * - 如果需要定制已知的数据源(即已有数据成员),则可重载此方法,例 |
| | | * |
| | |
| | | // 备用数据源 |
| | | $this->headers = $this->getAllHeaders(); |
| | | $this->get = $_GET; |
| | | $this->post = !empty($_POST)?$_POST:file_get_contents('php://input'); |
| | | $this->post = $_POST; |
| | | $this->request = $_REQUEST; |
| | | $this->cookie = $_COOKIE; |
| | | |
| | | @list($this->apiName, $this->actionName) = explode('.', $this->getService()); |
| | | } |
| | | |
New file |
| | |
| | | <?php |
| | | |
| | | class MyRequest extend PhalApi_Request{ |
| | | public function __construct($data = NULL) { |
| | | parent::__construct($data); |
| | | |
| | | // json处理 |
| | | $this->post = json_decode(file_get_contents('php://input'), TRUE); |
| | | print_r($this->post); |
| | | // 普通xml处理 |
| | | //$this->post = simplexml_load_string ( |
| | | // file_get_contents('php://input'), |
| | | // 'SimpleXMLElement', |
| | | // LIBXML_NOCDATA |
| | | //); |
| | | //$this->post = json_decode(json_encode($this->post), TRUE); |
| | | } |
| | | } |
| | | |
| | |
| | | //装载你的接口 |
| | | DI()->loader->addDirs('Yfs'); |
| | | |
| | | |
| | | /** ---------------- 响应接口请求 ---------------- **/ |
| | | $api = new PhalApi(); |
| | | $rs = $api->response(); |
| | |
| | | */ |
| | | |
| | | require_once dirname(__FILE__) . '/../init.php'; |
| | | DI()->loader->loadFile('Library/MyRequest.php'); |
| | | DI()->request = new MyRequest(); |
| | | |
| | | //装载你的接口 |
| | | DI()->loader->addDirs(array('Yfs', 'Library')); |
| | | |
| | | /** ---------------- 响应接口请求 ---------------- **/ |
| | | |
| | | $api = new PhalApi(); |
| | |
| | | public function getRules() { |
| | | return array( |
| | | 'upload' => array( |
| | | 'data' => array('name' => 'data', 'type' => 'array' ,'require' => true, 'desc' => '上传数据'), |
| | | 'data' => array('name' => 'data', 'type' => 'array', 'format' => 'json' ,'require' => true, 'desc' => '上传数据'), |
| | | ), |
| | | 'getUserDataList' => array( |
| | | 'user_id' => array( |