Class for handling the JSON API requests.
The user should derive from this class and implement the methods with the names of the API actions.
URL: http://smartfactorydev.loc/api/login/
Action: login
function login()
{
if (empty($this->request_data["login"]) || empty($this->request_data["password"]) ||
$this->request_data["login"] != "admin" || $this->request_data["password"] != "qwerty") {
throw new SmartException("Wrong login or password!", "wrong_login");
}
$this->response_data["welcome_msg"] = "Welcome, admin!";
}
| Properties | |
|---|---|
|
protected
|
Internal variable for storing the request data. |
|
protected
|
Internal variable for storing the response data. |
| Methods | |
|---|---|
|
protected
|
This is an auxiliary function for parsing the incoming JSON data. |
|
protected
|
This is an auxiliary function for sending the response in JSON format. |
Internal variable for storing the request data.
Internal variable for storing the response data.
This is an auxiliary function for parsing the incoming JSON data.
It validates the content type 'application/json' and takes the data from RAWDATA.
It might throw an exception if the content type oк JSON data is invalid.
This is an auxiliary function for sending the response in JSON format.
It sends the collected response data and the response headers. The header "Content-type: application/json; charset=UTF-8" ist sent automatically.