1. Go to this page and download the library: Download fw4/whise-api 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/ */
fw4 / whise-api example snippets
use Whise\Api\WhiseApi;
$api = new WhiseApi();
// Retrieve existing access token from storage (getAccessTokenFromDataStore to be implemented)
$accessToken = getAccessTokenFromDataStore();
if (!$accessToken) {
// Request and store new access token (saveAccessTokenToDataStore to be implemented)
$accessToken = $api->requestAccessToken('username', 'password');
saveAccessTokenToDataStore($accessToken);
}
$api->setAccessToken($accessToken);
$estates = $api->estates()->list();
// Traversing over the response takes care of pagination in the background
foreach ($estates as $estate) {
echo $estate->name . PHP_EOL;
}
use Cache\Adapter\Redis\RedisCachePool;
$redis = new \Redis();
$redis->connect('127.0.0.1', 6379);
$cache = new RedisCachePool($redis);
$api = new Whise\Api\WhiseApi($access_token);
$api->setCache($cache);
$estate = $api->estates()->get(1);
if ($estate->isCacheHit()) {
echo 'Response fetched from cache' . PHP_EOL;
} else {
echo 'Response fetched from API' . PHP_EOL;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.