Frequently Asked Questions (API)
This article was last updated 37 days ago, please note whether the content is still available
Output Custom JSON Format (Supported in 1.7.2)
The system API defaults to outputting JSON content with fields code, data, error, and message.
How to output custom fields? For example, outputting errno, msg fields:
//Define the return array within the API output function like this
$array['errno'] = 0;
$array['msg'] = 'success';
$array['data']['isConsumed'] = 2;
return array('json' => $array);Output XML Format and Other Data Formats (Supported in 1.7.2)
The system API defaults to JSON format. How to output other data formats:
//Define the return array within the API output function like this $array $array['raw'] = '0okxml info'; $array['raw-type'] = 'text/xml'; return $array;
Skip CSRF Token Verification When Accessing API Anonymously (POST Request)
If you define a newapi/submit API for non-logged-in users to use via POST, you need to append csrf_token to the API's URL. If you do not want to use csrf_token,
you can use the interface settings to bypass CSRF token verification.
Add_Filter_Plugin('Filter_Plugin_API_VerifyCSRF_Skip', 'newapi_IgnoreCSRF');
function newapi_IgnoreCSRF(&$array)
{
$array[] = array('mod' => 'newapi', 'act' => 'submit');
}Apache Cannot Get Authorization Header Information
Modify the .htaccess file and add the following information:
RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization},last]
This article was posted by @GebiLaoli on LaoLi Docs, if you have any questions, please contact us.
Article link: http://docs.zbp.cool/zblogdocs/zblogapi/21.html
Article link: http://docs.zbp.cool/zblogdocs/zblogapi/21.html
Helpful?
2025-10-10 10:54:14
2025-10-10 10:50:56