abstract class WebServiceUtilityBase in Smart IP 8.2
Same name and namespace in other branches
- 8.4 src/WebServiceUtilityBase.php \Drupal\smart_ip\WebServiceUtilityBase
- 8.3 src/WebServiceUtilityBase.php \Drupal\smart_ip\WebServiceUtilityBase
Web service utility methods class wrapper.
@package Drupal\smart_ip
Hierarchy
- class \Drupal\smart_ip\WebServiceUtilityBase implements WebServiceUtilityInterface
Expanded class hierarchy of WebServiceUtilityBase
1 file declares its use of WebServiceUtilityBase
- WebServiceUtility.php in modules/
smart_ip_ipinfodb_web_service/ src/ WebServiceUtility.php - Contains \Drupal\smart_ip_ipinfodb_web_service\WebServiceUtility.
File
- src/
WebServiceUtilityBase.php, line 15 - Contains \Drupal\smart_ip\WebServiceUtilityBase.
Namespace
Drupal\smart_ipView source
abstract class WebServiceUtilityBase implements WebServiceUtilityInterface {
/**
* {@inheritdoc}
*/
public static function sendRequest($url = NULL) {
if (!empty($url)) {
try {
$response = \Drupal::httpClient()
->get($url, array(
'headers' => array(
'Accept' => 'application/json',
),
));
$data = (string) $response
->getBody();
if (empty($data)) {
\Drupal::logger('smart_ip')
->error(t('Empty response from @url', [
'@url' => $url,
]));
}
else {
return $data;
}
} catch (\Exception $e) {
\Drupal::logger('smart_ip')
->error(t('Sending request failed: @error', [
'@error' => $e
->getMessage(),
]));
}
}
return '';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
WebServiceUtilityBase:: |
public static | function |
Perform HTTP request to the Smart IP's data source module web service. Overrides WebServiceUtilityInterface:: |
|
WebServiceUtilityInterface:: |
public static | function | Perform HTTP request and decoding the raw Geolocation data returned by Smart IP's data source module web. | 1 |
WebServiceUtilityInterface:: |
public static | function | Get Smart IP's data source module's web service URL. | 1 |