1. Go to this page and download the library: Download lessmore92/api-consumer 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/ */
lessmore92 / api-consumer example snippets
PHP >=5.5
$this->Request()
$this->Request()
use Lessmore92\ApiConsumer\ApiConsumer;
use Lessmore92\ApiConsumer\Builders\ApiBuilder;
class MyApi extends ApiConsumer
{
/**
* @return ApiBuilder
*/
protected function ConfigApi()
{
$api = new ApiBuilder();
$api->setHeaderApiKey('API-TOKEN','X-API-Key');
$api->setBaseUrl('https://MY-API-BASE-URL.COM/');
return $api;
}
public function Users()
{
$users = $this->Request()
->Endpoint('users')
->Get()
;
return $users->body;
}
}
public function SearchUsers($search)
{
$users = $this->Request()
->Endpoint('users')
->AddQueryString('search', $search)
->Get()
;
return $users->json_body;
}
public function SearchUsers($search)
{
$users = $this->Request()
->Endpoint('users')
->AcceptJson()
->Get()
;
return $users->json_body;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.