colly_wyx
2018-04-24 eed5862fcd0c09cd03d3e1e5d82e0f33720ac10b
兼容
2 files added
5 files modified
48 ■■■■ changed files
Library/MyRequest.php 19 ●●●●● patch | view | raw | blame | history
PhalApi/PhalApi/Loader.php 1 ●●●● patch | view | raw | blame | history
PhalApi/PhalApi/Request.php 3 ●●●● patch | view | raw | blame | history
Public/Request/MyRequest.php 19 ●●●●● patch | view | raw | blame | history
Public/index.php 1 ●●●● patch | view | raw | blame | history
Public/yfs/index.php 3 ●●●● patch | view | raw | blame | history
Yfs/Api/Data.php 2 ●●● patch | view | raw | blame | history
Library/MyRequest.php
New file
@@ -0,0 +1,19 @@
<?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);
  }
}
PhalApi/PhalApi/Loader.php
@@ -97,7 +97,6 @@
    protected function loadClass($path, $className) {
        $toRequireFile = $path . DIRECTORY_SEPARATOR 
            . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
        if (file_exists($toRequireFile)) {
            require_once $toRequireFile;
            return TRUE;
PhalApi/PhalApi/Request.php
@@ -83,10 +83,9 @@
        // 备用数据源
        $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());
    }
Public/Request/MyRequest.php
New file
@@ -0,0 +1,19 @@
<?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);
  }
}
Public/index.php
@@ -8,6 +8,7 @@
//装载你的接口
DI()->loader->addDirs('Yfs');
/** ---------------- 响应接口请求 ---------------- **/
$api = new PhalApi();
$rs = $api->response();
Public/yfs/index.php
@@ -4,10 +4,11 @@
 */
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();
Yfs/Api/Data.php
@@ -8,7 +8,7 @@
    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(