Addons:API
The API environment can be used to provide functions that can be used by other applications with or without an API key. It's a clean site, but with all variables, classes and functions that GExtension has. The api file is then available under api.php?t=<rawname>[$key=...].
Security Check
To verify that the file was included by GExtension, it's required to include the following code at the beginning of the file:
<?php if(!isset($G_API)){ die(json_encode(array("error" => "authentification failed"))); } ?>
Structure
You should use the RequiredArguments($arg1, $arg2, ...) function to check if specified POST/GET paramters are given. All given paramters will be transformed into global variables with the same name or the user will get an error message.
If you are providing multiple actions on your API page, you should use the "action" paramter.
No Login
By default, using an API page requires the API key which can be found in the settings. To make a file public, you need to run the following function once (may put it in the install.php):
NoAuthFiles::Add('api', '<rawname>');