API Documentation
API Address Pattern: https://example.com/zb_system/api.php?mod=<module_name>[&act=<action_name>][&other...]
For
act=postrequests of each "API module", the request parameters are the data field definitions corresponding to the module in$GLOBALS['datainfo'];Parameter field names are case-sensitive;
It is not necessary to provide values for all fields. For example, items such as "publish status", "type (article/page)", and "sticky" can use defaults, while time-related fields will be initialized to the current time;
Except for
CommentandUpload, theIDfield must be specified foract=postrequests. A value of 0 creates a new entry, while a non-zero value that exists modifies the entry;Note: You can search for
$GLOBALS['datainfo']in the file "zb_system/defend/datainfo.php" to view it;The actual return information for each interface shall prevail. Please refer to the "General Return Format".
For
POSTrequests other than "login", authentication must be set;"Login and Authentication"
For
GETrequests, authentication is only required for some "read-only operations" within some "functional modules". Unauthenticated requests may be limited in frequency or query quantity;
The following will be described in detail by "functional module".
member Member Login and Management API
| act Method | Request Method | Parameters | Authentication |
|---|---|---|---|
login | POST | Login user and return token | |
| $_POST['username'] Username (not nickname) | |||
$_POST['password']password MD5 (plaintext password) value is recommended | |||
$_POST['savedate']token expiration time, up to 365 days | |||
| Return value: Attached: "Example 1" | |||
post | POST | Edit or create user | Required |
Member defined fields; Attached: "Example 2" | |||
get | GET / POST | Get user information | Required |
$_REQUEST['id'] User id | |||
delete | GET / POST | Delete a user | Required |
$_REQUEST['id'] User id | |||
list | GET / POST | Get user management list | Required |
act=list common parameters for the method, see: Constraints and Filtering | |||
$_REQUEST['status'] Specify status status | |||
$_REQUEST['level'] Specify user level | |||
| $_REQUEST['page'] Page number 'page' | |||
get_auth | GET / POST | View current user permission list | Required |
logout | GET / POST | Log out | Required |
| PS: Then the client can delete the token on their own. | |||
Example 1:
login Successful login return value: (Click to expand)
//POST fields sent as follows
username = 'username'
password = md5('plaintext_password')
savedate = 'days_to_save'
{
"code": 200,
"message": "Operation successful",
"data": {
"user": {
"ID": "1",
"Level": "1",
"Status": "0",
"Name": "admin",
"StaticName": "admin" // etc. member-related information
},
"token": "Token information",
"expire_time": 1672560322 // expiration time
},
"error": null,
"runtime": {
}
}
The "Authentication Token" returned by the login operation here will be used for subsequent requests that require "authentication". See "Permission Authentication";
Example 2:
post Create a user: (Click to expand)
{
"ID": "0",
"Level": "4",
"Name": "username",
"Password": "zblog_pwdd",
"PasswordRe": "zblog_pwdd"
}
"ID": "0", must be explicitly set;
"Level": "4", is the user level; refer to "User Level Definition"
post Article Management API
| act Method | Request Method | Parameters | Authentication |
|---|---|---|---|
get | GET / POST | Get article | Authentication required for non-public articles |
| Parameter id: Article ID | |||
| Parameter with_relations: Additional related objects | e.g.: mod=post&act=get&id=2&with_relations=Author Returns the Author object as well | ||
| 1.7.2 New parameter viewnums: Refresh view count simultaneously | e.g.: mod=post&act=get&id=2&viewnums=1 | ||
post | POST | Create or edit article | Required |
Post form field definition; Attached: "Example 1" | |||
delete | GET / POST | Delete article | Required |
$_REQUEST['id'] Article id | |||
list | GET / POST | Get article list | Unauthenticated requests are limited to the display quantity per page. |
| $_REQUEST parameter definition as follows: | |||
cate_id, tag_id, auth_id, type, date, manage, search | Authenticated requests with backend management privileges are limited to the display quantity per page in the backend. | ||
act=list common parameters for the method, see: Constraints and Filtering | |||
| Parameter with_relations: Additional related objects | e.g.: mod=post&act=get&id=2&with_relations=Author Returns the Author object as well | ||
| 1.7.2.3045 Added parameter with_subcate: Can output articles in subcategories in category lists | e.g.: mod=post&act=list&cate_id=2&with_subcate=1 | ||
Example 1:
post Sample $_POST parameters for creating or publishing an article: (Click to expand)
$_POST['ID'] is 0 for new creation $_POST['Title'] $_POST['Alias'] $_POST['Type'] is 0 for article, 1 for page $_POST['AuthorID'] $_POST['CateID'] If CateID is not provided, CateName can be provided $_POST['Intro'] $_POST['Content'] $_POST['Tag'] $_POST['PostTime'] $_POST['Status'] Status
Note: For publishing articles, an additional CateName field can be provided to replace CateID for specifying the category, provided that a category with that name exists; you can also use the interfaces within the category module to achieve operations like automatic category creation;
app Application Management API
| act Method | Request Method | Parameters | Authentication |
|---|---|---|---|
get | GET / POST | Get application of specified type and id | Authentication required |
type is theme or plugin | |||
id is the id value of the application | |||
get_apps | GET / POST | Get all application lists (including inactive ones) | Authentication required |
get_themes | GET / POST | Get all theme lists (including inactive ones) | Authentication required |
get_plugins | GET / POST | Get all plugin lists (including inactive ones) | Authentication required |
set_theme | POST | Activate specified theme | Authentication required |
$_POST['id] id is the id value of the theme | |||
$_POST['style] style is the style name of the theme | |||
enable_plugin | POST | Enable specified plugin | Authentication required |
$_POST['id] id is the id value of the plugin | |||
disable_plugin | POST | Disable specified plugin | Authentication required |
$_POST['id] id is the id value of the plugin | |||
category Category Management API
| act Method | Request Method | Parameters | Authentication |
|---|---|---|---|
get | GET / POST | Get category of specified id | No authentication required |
id is the id value of the category | |||
post | POST | Edit or create category | Authentication required |
delete | GET / POST | Delete category | Authentication required |
list | GET / POST | List categories | &manage=1 (management mode) requires authentication |
comment Comment Management API
| act Method | Request Method | Parameters | Authentication |
|---|---|---|---|
get | GET / POST | Get comment of specified id | No authentication required |
Parameter id: is the id value of the comment | |||
post | POST | Post comment | Authentication required |
| POST parameters: Attached: "Example 1" | |||
delete | GET / POST | Delete comment | Authentication required |
Parameter id: is the id value of the comment | |||
list | GET / POST | List comments | Management mode requires authentication |
| Parameter manage: Enter management mode | e.g.: &manage=1 | ||
check | GET / POST | Approve comment | Authentication required |
Parameter id: is the id value of the comment | |||
Parameter ischecking: approval status | e.g.: &ischecking=1, pending approval | ||
batch | POST | Batch process comments | Authentication required |
Parameters all_del, all_pass, all_audit indicate delete all, pass, pending approval | e.g.: &all_pass=1 | ||
| Parameter $_POST['id]: Array of comment IDs to be processed in batch | |||
Example 1:
post Sample $_POST parameters for posting a comment: (Click to expand)
$_POST['LogID'] is the ID of the article the comment is for $_POST['Name'] commenter's name $_POST['ReplyID'] ID of the comment being replied to $_POST['Email'] commenter's email $_POST['HomePage'] commenter's website $_POST['Content'] comment body
module Module and Sidebar Management API
| act Method | Request Method | Parameters | Authentication |
|---|---|---|---|
get | GET / POST | Get module of specified id | No authentication required |
id is the id value of the module | |||
post | POST | Edit or create module | Authentication required |
| POST parameters: Attached: "Example 1" | |||
delete | GET / POST | Delete module | Authentication required |
id is the id value of the module | |||
list | GET / POST | List modules | No authentication required |
set_sidebar | POST | Set sidebar | Authentication required |
list_sidebar | GET / POST | List specified sidebar | Authentication required |
id is the id value of the sidebar (1-9) | |||
Example 1:
post Sample $_POST parameters for creating or editing a module: (Click to expand)
$_POST['ID'] is 0 for new creation $_POST['FileName'] Unique identifier of the module, naming must follow file name rules $_POST['HtmlID'] HTML id of the module $_POST['MaxLi'] Maximum number of li tags within the module $_POST['IsHideTitle'] Whether to hide the module's title $_POST['Type'] Module type, either div or ul $_POST['Content'] Module content $_POST['NoRefresh'] Lock module content from program updates
system System Settings and Management API
| act Method | Request Method | Parameters | Authentication |
|---|---|---|---|
basic_info | GET / POST | Get website basic information | Not required |
| PS: If authentication is sent, the system language package array will be returned additionally. | |||
get_info | GET / POST | Get website advanced information | Authentication required |
misc_statistic | GET / POST | Clear cache and recompile templates | Authentication required |
| PS: This is the refresh cache operation in the backend. | |||
misc_showtags | GET / POST | Misc get common tags | Authentication required |
Parameter type = 0, which means getting common tags for articles | |||
get_setting | GET / POST | Get common settings array | Authentication required |
| Return value: Returns the common option array. | |||
save_setting | POST | Save system common settings | Authentication required |
| Attached: "Example 1" | |||
Example 1:
get_setting and save_setting can return or set option values: (Click to expand)
$GLOBALS['setting_keys'] = array( 'ZC_BLOG_NAME', 'ZC_BLOG_SUBNAME', 'ZC_BLOG_COPYRIGHT', 'ZC_TIME_ZONE_NAME', 'ZC_BLOG_LANGUAGEPACK', 'ZC_API_ENABLE', 'ZC_XMLRPC_ENABLE', 'ZC_DEBUG_MODE', 'ZC_DEBUG_MODE_WARNING', 'ZC_ADDITIONAL_SECURITY', 'ZC_USING_CDN_GUESTIP_TYPE', 'ZC_CLOSE_SITE', 'ZC_DISPLAY_COUNT', 'ZC_DISPLAY_SUBCATEGORYS', 'ZC_PAGEBAR_COUNT', 'ZC_SEARCH_COUNT', 'ZC_SYNTAXHIGHLIGHTER_ENABLE', 'ZC_COMMENT_TURNOFF', 'ZC_COMMENT_AUDIT', 'ZC_COMMENT_REVERSE_ORDER', 'ZC_COMMENTS_DISPLAY_COUNT', 'ZC_COMMENT_VERIFY_ENABLE', 'ZC_UPLOAD_FILETYPE', 'ZC_UPLOAD_FILESIZE', 'ZC_ARTICLE_INTRO_WITH_TEXT', 'ZC_ARTICLE_THUMB_SWITCH', 'ZC_ARTICLE_THUMB_TYPE', 'ZC_ARTICLE_THUMB_WIDTH', 'ZC_ARTICLE_THUMB_HEIGHT', 'ZC_MANAGE_COUNT', 'ZC_POST_BATCH_DELETE', 'ZC_DELMEMBER_WITH_ALLDATA', 'ZC_CATEGORY_MANAGE_LEGACY_DISPLAY', );
tag Tag Management API
| act Method | Request Method | Parameters | Authentication |
|---|---|---|---|
get | GET / POST | Get tag of specified id | No authentication required |
Parameter id: is the id value of the attachment | |||
post | POST | Edit or create tag | Authentication required |
| POST parameters: Attached: "Example 1" | |||
delete | GET / POST | Delete tag | Authentication required |
Parameter id: is the id value of the attachment | |||
list | GET / POST | List tags | Management mode requires authentication |
| Parameter manage: Enter management mode | e.g.: &manage=1 | ||
Example 1:
post Sample $_POST parameters for creating or editing a tag: (Click to expand)
$_POST['ID'] is 0 for new creation $_POST['Alias'] Alias of the tag $_POST['Intro'] Introduction to the tag $_POST['Template'] Tag template, defaults to empty
upload Attachment Management API
| act Method | Request Method | Parameters | Authentication |
|---|---|---|---|
get | GET / POST | Get attachment of specified id | Authentication required |
Parameter id: is the id value of the attachment | |||
post | POST | Edit or create attachment | Authentication required |
| Attached: "Example 1" | |||
delete | GET / POST | Delete attachment | Authentication required |
Parameter id: is the id value of the attachment | |||
list | GET / POST | List attachments | Authentication required |
| Parameter manage: Enter management mode | e.g.: &manage=1 | ||
| Parameter author_id: List attachments under user ID author_id | |||
| Parameter post_id: List attachments under post ID post_id |
Example 1:
post Submit a new attachment: (Click to expand)
The client or mini-program POSTs the uploaded file to mod=upload&act=post
After successful submission, the json($upload) object is, for example:
{"code":200,"message":"Operation successful","data":
{"upload":{"ID":118,"AuthorID":"1","Size":100676,
"Name":"tmp_14af3ac3791ceeb34e0755ccc3586ce2.jpg",
"SourceName":"tmp_14af3ac3791ceeb34e0755ccc3586ce2.jpg",
"MimeType":"image/jpeg","PostTime":1648973749,
"DownNums":0,"LogID":0,"Intro":"","Url":"xxxxxxxxxxxxxxx"}
},"error":null,
"runtime":{"time":"54.25","query":14,"memory":4035,"debug":0,"loggedin":1,"error":0}
}
Returns false after submission failure
Article link: https://docs.zbp.cool/zblogdocs/zblogapi/19.html
Helpful?
2025-10-10 10:38:22