Menu

API Documentation

This article was last updated 37 days ago, please note whether the content is still available

API Address Pattern: https://example.com/zb_system/api.php?mod=<module_name>[&act=<action_name>][&other...]

  • For act=post requests 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 Comment and Upload, the ID field must be specified for act=post requests. 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 POST requests other than "login", authentication must be set;

    "Login and Authentication"

    • For GET requests, 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 MethodRequest MethodParametersAuthentication
loginPOSTLogin 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"




postPOSTEdit or create userRequired


Member defined fields; Attached: "Example 2"




getGET / POSTGet user informationRequired


$_REQUEST['id'] User id




deleteGET / POSTDelete a userRequired


$_REQUEST['id'] User id




listGET / POSTGet user management listRequired


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_authGET / POSTView current user permission listRequired




logoutGET / POSTLog outRequired


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 MethodRequest MethodParametersAuthentication
getGET / POSTGet articleAuthentication required for non-public articles


Parameter id: Article ID


Parameter with_relations: Additional related objectse.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 simultaneouslye.g.: mod=post&act=get&id=2&viewnums=1




postPOSTCreate or edit articleRequired


Post form field definition; Attached: "Example 1"




deleteGET / POSTDelete articleRequired


$_REQUEST['id'] Article id




listGET / POSTGet article listUnauthenticated requests are limited to the display quantity per page.


$_REQUEST parameter definition as follows:


cate_id, tag_id, auth_id, type, date, manage, searchAuthenticated 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 objectse.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 listse.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 MethodRequest MethodParametersAuthentication
getGET / POSTGet application of specified type and idAuthentication required


type is theme or plugin


id is the id value of the application




get_appsGET / POSTGet all application lists (including inactive ones)Authentication required




get_themesGET / POSTGet all theme lists (including inactive ones)Authentication required




get_pluginsGET / POSTGet all plugin lists (including inactive ones)Authentication required




set_themePOSTActivate specified themeAuthentication required


$_POST['id] id is the id value of the theme


$_POST['style] style is the style name of the theme




enable_pluginPOSTEnable specified pluginAuthentication required


$_POST['id] id is the id value of the plugin




disable_pluginPOSTDisable specified pluginAuthentication required


$_POST['id] id is the id value of the plugin




category Category Management API

act MethodRequest MethodParametersAuthentication
getGET / POSTGet category of specified idNo authentication required


id is the id value of the category
postPOSTEdit or create categoryAuthentication required
deleteGET / POSTDelete categoryAuthentication required
listGET / POSTList categories&manage=1 (management mode) requires authentication




comment Comment Management API

act MethodRequest MethodParametersAuthentication
getGET / POSTGet comment of specified idNo authentication required


Parameter id: is the id value of the comment
postPOSTPost commentAuthentication required


POST parameters: Attached: "Example 1"
deleteGET / POSTDelete commentAuthentication required


Parameter id: is the id value of the comment
listGET / POSTList commentsManagement mode requires authentication


Parameter manage: Enter management modee.g.: &manage=1
checkGET / POSTApprove commentAuthentication required


Parameter id: is the id value of the comment


Parameter ischecking: approval statuse.g.: &ischecking=1, pending approval
batchPOSTBatch process commentsAuthentication required


Parameters all_del, all_pass, all_audit indicate delete all, pass, pending approvale.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 MethodRequest MethodParametersAuthentication
getGET / POSTGet module of specified idNo authentication required


id is the id value of the module
postPOSTEdit or create moduleAuthentication required


POST parameters: Attached: "Example 1"
deleteGET / POSTDelete moduleAuthentication required


id is the id value of the module
listGET / POSTList modulesNo authentication required
set_sidebarPOSTSet sidebarAuthentication required
list_sidebarGET / POSTList specified sidebarAuthentication 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 MethodRequest MethodParametersAuthentication
basic_infoGET / POSTGet website basic informationNot required


PS: If authentication is sent, the system language package array will be returned additionally.




get_infoGET / POSTGet website advanced informationAuthentication required




misc_statisticGET / POSTClear cache and recompile templatesAuthentication required


PS: This is the refresh cache operation in the backend.




misc_showtagsGET / POSTMisc get common tagsAuthentication required


Parameter type = 0, which means getting common tags for articles




get_settingGET / POSTGet common settings arrayAuthentication required


Return value: Returns the common option array.




save_settingPOSTSave system common settingsAuthentication 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 MethodRequest MethodParametersAuthentication
getGET / POSTGet tag of specified idNo authentication required


Parameter id: is the id value of the attachment
postPOSTEdit or create tagAuthentication required


POST parameters: Attached: "Example 1"
deleteGET / POSTDelete tagAuthentication required


Parameter id: is the id value of the attachment
listGET / POSTList tagsManagement mode requires authentication


Parameter manage: Enter management modee.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 MethodRequest MethodParametersAuthentication
getGET / POSTGet attachment of specified idAuthentication required


Parameter id: is the id value of the attachment
postPOSTEdit or create attachmentAuthentication required


Attached: "Example 1"
deleteGET / POSTDelete attachmentAuthentication required


Parameter id: is the id value of the attachment
listGET / POSTList attachmentsAuthentication required


Parameter manage: Enter management modee.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

Helpful?

Comments(1)

剑影飞鸿
剑影飞鸿

2025-10-10 10:38:22

详细介绍了Zblog系统的API接口及其使用方法。

Post comment

Support Live Chat
TOP