1. Go to this page and download the library: Download openclerk/apis library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
openclerk / apis example snippets
/**
* API to get a single currency properties.
*/
class Currency extends \Apis\Api {
function getJSON($arguments) {
$cur = \DiscoveredComponents\Currencies::getInstance($arguments['currency']);
$result = array(
'code' => $cur->getCode(),
'title' => $cur->getName(),
);
return $result;
}
function getEndpoint() {
return "/api/v1/currency/:currency";
}
}
// load up API routes
foreach (DiscoveredComponents\Apis::getAllInstances() as $uri => $handler) {
\Openclerk\Router::addRoutes(array(
$uri => $handler,
));
}
/**
* API to get a single currency properties.
*/
class Currency extends \Apis\CachedApi {
// ...
function getHash($arguments) {
return substr($arguments['currency'], 0, 32);
}
function getAge() {
return 60; /* cache age in seconds */
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.