private function Client::doRequest in Instagram API 8
Guzzle request for Instagram.
Parameters
string $url: Url.
array $parameters: Parameters.
string $requestMethod: Request method.
Return value
bool|array False or array.
1 call to Client::doRequest()
- Client::request in src/
Service/ Client.php - Instagram request.
File
- src/
Service/ Client.php, line 183
Class
- Client
- Class Client.
Namespace
Drupal\instagram_api\ServiceCode
private function doRequest($url, array $parameters = [], $requestMethod = 'GET') {
if ($this->access_token == "") {
$msg = $this
->t('Instagram API Access Token is not set. It can be set on the <a href=":config_page">configuration page</a>.', [
':config_page' => Url::fromRoute('instagram_api.settings'),
]);
drupal_set_message($msg, 'error');
return FALSE;
}
try {
$response = $this->guzzleClient
->request($requestMethod, $url, [
'query' => $parameters,
]);
if ($response
->getStatusCode() == 200) {
$contents = $response
->getBody()
->getContents();
$json = Json::decode($contents);
return $json['data'];
}
} catch (GuzzleException $e) {
$this->loggerFactory
->get('instagram_api')
->error("@message", [
'@message' => $e
->getMessage(),
]);
return FALSE;
}
}