PHP code example of jiechengyang / i-secure-center
1. Go to this page and download the library: Download jiechengyang/i-secure-center library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jiechengyang / i-secure-center example snippets
abstract class BaseApi
{
protected $error;// 用于存放接口必填参数未填的错误
protected $_uriMap;// 接口的方法与接口地址的映射,每个接口类都预先设置好的
protected $requestUri;// 接口地址
public $requestBody;// 接口请求参数
/**
* @return mixed
*/
public function getUriMap()
{
return $this->_uriMap;
}
/**
* @return mixed
*/
public function getRequestUri()
{
return $this->requestUri;
}
/**
* @return mixed
*/
public function getRequestBody()
{
return $this->requestBody;
}
public function setRequestBody($requestBody)
{
$this->requestBody = $requestBody;
}
/**
* 获取action对应的地址
* @return mixed
*/
public function getUri($action)
{
if (empty($action) || empty($this->_uriMap[$action])) {
return null;
}
$this->requestUri = $this->_uriMap[$action];
return $this->requestUri;
}
/**
* 接口存在该方法便调用
* @return bool
*/
public function runAction($action, $message = [])
{
if (!is_callable([$this, $action])) {
return false;
}
call_user_func([$this, $action], $message);
return true;
}
public function getError()
{
return $this->error;
}
public function getErrorFormat($glue = PHP_EOL)
{
return implode($glue, $this->getError());
}
public function setError($error)
{
$this->error = $error;
}
}