Local API Call (1.7.3 Supported)
1.7.3 Added the ApiExecute function, which can be used to call and execute APIs from public modules and private modules and return the results.
Function Definition:
/**
* API Execution.
*
* @param string $mod (Module Name)
* @param string $act (Method Name)
* @param array $get (Simulated $_GET parameters)
* @param array $post (Simulated $_POST parameters)
*/
function ApiExecute($mod, $act, $get = array(), $post = array())
{...}Example:
$post = ApiExecute('post', 'get', array('id' => 2));
var_dump($post);
// Calls the get method of the post module, with GET parameter id=2, and returns the result (array of article data)The purpose of the ApiExecute function is to allow access to APIs while also executing other API calls via ApiExecute. Of course, it can also be called from other parts of the system.
Private Modules
The difference between private modules and public modules is that public modules can be accessed by the api.php route and called by the ApiExecute function.
Private modules can only be called by the ApiExecute function within the system and will not be accessed by the api.php route.
Loading and Removing Private Modules
Add private modules from the specified directory at once, where $modsdir is the directory where the private modules are located.
ApiLoadPrivateMods($modsdir)
Add a private module individually.
ApiAddMod($modname, $filename)
Remove a private module individually.
ApiRemovePrivateMod($modname)
Article link: http://docs.zbp.cool/zblogdocs/zblogapi/22.html
Helpful?
Post comment