Skip to content

kimor79/api_producer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

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);

About

Server-side API producer

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages