* Fix error of comment.
This commit is contained in:
@@ -3667,6 +3667,76 @@ EOF;
|
||||
return static::apiError($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Post method of API.
|
||||
*
|
||||
* @param string $url
|
||||
* @param array|object $data
|
||||
* @param array $headers example: array("key1:value1", "key2:value2")
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public static function apiPost($url, $data, $headers = array())
|
||||
{
|
||||
$result = json_decode(commonModel::http($url, $data, array(CURLOPT_CUSTOMREQUEST => 'POST'), $headers, 'json'));
|
||||
if($result && $result->code == 200) return $result;
|
||||
|
||||
return static::apiError($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Put method of API.
|
||||
*
|
||||
* @param string $url
|
||||
* @param array|object $data
|
||||
* @param array $headers example: array("key1:value1", "key2:value2")
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public static function apiPut($url, $data, $headers = array())
|
||||
{
|
||||
$result = json_decode(commonModel::http($url, $data, array(CURLOPT_CUSTOMREQUEST => 'PUT'), $headers, 'json'));
|
||||
if($result && $result->code == 200) return $result;
|
||||
|
||||
return static::apiError($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete method of API.
|
||||
*
|
||||
* @param string $url
|
||||
* @param array|object $data
|
||||
* @param array $headers example: array("key1:value1", "key2:value2")
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public static function apiDelete($url, $data, $headers = array())
|
||||
{
|
||||
$result = json_decode(commonModel::http($url, $data, array(CURLOPT_CUSTOMREQUEST => 'DELETE'), $headers, 'json'));
|
||||
if($result && $result->code == 200) return $result;
|
||||
|
||||
return static::apiError($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return error object of api server.
|
||||
*
|
||||
* @param object|null $result
|
||||
* @access protected
|
||||
* @return object
|
||||
*/
|
||||
protected static function apiError($result)
|
||||
{
|
||||
global $lang;
|
||||
|
||||
if($result && $result->code) return $result;
|
||||
|
||||
$error = new stdclass;
|
||||
$error->code = 600;
|
||||
$error->message = $lang->error->httpServerError;
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check object priv.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user