class WebServiceUtility in Smart IP 8.3
Same name in this branch
- 8.3 modules/smart_ip_ipinfodb_web_service/src/WebServiceUtility.php \Drupal\smart_ip_ipinfodb_web_service\WebServiceUtility
- 8.3 modules/smart_ip_abstract_web_service/src/WebServiceUtility.php \Drupal\smart_ip_abstract_web_service\WebServiceUtility
- 8.3 modules/smart_ip_maxmind_geoip2_web_service/src/WebServiceUtility.php \Drupal\smart_ip_maxmind_geoip2_web_service\WebServiceUtility
Same name and namespace in other branches
- 8.4 modules/smart_ip_maxmind_geoip2_web_service/src/WebServiceUtility.php \Drupal\smart_ip_maxmind_geoip2_web_service\WebServiceUtility
Utility methods class wrapper.
@package Drupal\smart_ip_maxmind_geoip2_web_service
Hierarchy
- class \Drupal\smart_ip\WebServiceUtilityBase implements WebServiceUtilityInterface
- class \Drupal\smart_ip_maxmind_geoip2_web_service\WebServiceUtility
Expanded class hierarchy of WebServiceUtility
See also
http://dev.maxmind.com/geoip/geoip2/web-services
1 file declares its use of WebServiceUtility
- SmartIpEventSubscriber.php in modules/
smart_ip_maxmind_geoip2_web_service/ src/ EventSubscriber/ SmartIpEventSubscriber.php - Contains \Drupal\smart_ip_maxmind_geoip2_web_service\EventSubscriber\SmartIpEventSubscriber.
File
- modules/
smart_ip_maxmind_geoip2_web_service/ src/ WebServiceUtility.php, line 21 - Contains \Drupal\smart_ip_maxmind_geoip2_web_service\WebServiceUtility.
Namespace
Drupal\smart_ip_maxmind_geoip2_web_serviceView source
class WebServiceUtility extends WebServiceUtilityBase {
/**
* {@inheritdoc}
*/
public static function getUrl($ipAddress = NULL) {
if (!empty($ipAddress)) {
$config = \Drupal::config(SmartIpEventSubscriber::configName());
$userId = $config
->get('user_id');
$licenseKey = $config
->get('license_key');
$serviceType = $config
->get('service_type');
return "https://{$userId}:{$licenseKey}@" . MaxmindGeoip2WebService::BASE_URL . "/{$serviceType}/{$ipAddress}";
}
return '';
}
/**
* {@inheritdoc}
*/
public static function getGeolocation($ipAddress = NULL) {
$url = self::getUrl($ipAddress);
$json = self::sendRequest($url);
$data = Json::decode($json);
return $data;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
WebServiceUtility:: |
public static | function |
Perform HTTP request and decoding the raw Geolocation data returned by
Smart IP's data source module web service. Overrides WebServiceUtilityInterface:: |
|
WebServiceUtility:: |
public static | function |
Get Smart IP's data source module's web service URL. Overrides WebServiceUtilityInterface:: |
|
WebServiceUtilityBase:: |
public static | function |
Perform HTTP request to the Smart IP's data source module web service. Overrides WebServiceUtilityInterface:: |