public function Client::request in Instagram API 8
Instagram request.
Parameters
string $method: Method to call.
array $args: Args to request.
bool $cacheable: Is it cachable.
Return value
bool|array Either an array or false.
File
- src/
Service/ Client.php, line 95
Class
- Client
- Class Client.
Namespace
Drupal\instagram_api\ServiceCode
public function request($method, array $args, $cacheable = TRUE) {
// Build the arg_hash.
$args = $this
->buildArgs($args, $method);
$argHash = $this
->buildArgHash($args);
// $response = &drupal_static(__FUNCTION__);
// // Can be replaced with the `__METHOD__`.
$cid = 'instagram_api:' . md5($argHash);
// Check cache.
if ($cache = $this->cacheBackend
->get($cid)) {
$response = $cache->data;
// Return result from cache if found.
return $response;
}
else {
$response = $this
->doRequest($method, $args);
if ($response) {
// Cache the response if we got one.
if ($this->api_cache_maximum_age != 0 && $cacheable == TRUE) {
$this->cacheBackend
->set($cid, $response, time() + $this->api_cache_maximum_age);
}
// Return result from source if found.
return $response;
}
}
// Tough luck, no results mate.
return FALSE;
}