kimor79/api_producer
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
Server-side functions for producing API output,
mainly for YUI consumers (eg datatable)
Basic flow:
$required = array(
'key1' => 'digit',
'key2' => NULL,
);
$optional = array(
'key3' => 'bool',
);
$sanitize = array(
'key2' => 'convertcase',
);
$api->setParameters();
$input = $api->setInput($_POST);
$errors = $api->validateInput($input, $required, $optional);
if(!empty($errors)) {
$api->showOutput(array(), 0, '400', implode("\n", $errors));
exit(0);
}
$input = $api->sanitizeInput($input);
...
// populate $records
$api->sendHeaders();
$api->showOutput($records, $total_records);