<?php
/*
Exemple of REST API for generate random number
*/
class SampleKeyValidator extends ApiKeyValidatorBase {
function isValid($key) {
/* Validade here using MySQL, etc... */
return ($key == "75f42660c4109c3dc81101d3a45fa174");
}
}
registerClass("Test_v1", "1");
/*
This class is Public (extends ApiCommandBase), don´t need Key for acess
*/
class Test_v1 extends ApiCommandBase {
function _getURIName() {
return "random";
}
function getNumber() {
return rand(0,100);
}
}
registerClass("Test_v2", "2");
/**
* TESTE This is a doc_comment.
* (see doc.php for view API Doc)
*/
class Test_v2 extends Test_v1 {
function getNumber() {
return rand(101,1000);
}
/**
* (en) Return number between <i>min</i> and <i>max</i>
* (pt-br) Retorna um número entre <i>min</i> e <i>max</i>
*/
function getNumberRange($min = 0, $max = 100) {
return rand($min,$max);
}
}
registerClass("Test_v3", "2");
/*
This class is Private (extends ApiComamndKeyed), need Key for acess
*/
class Test_v3 extends ApiComamndKeyed {
function getSecureString() {
return "string protected by Key";
}
function _getURIName() {
return "text";
}
}
?>
|