You are here

public static function WebServiceUtility::getGeolocation in Smart IP 8.3

Same name in this branch
  1. 8.3 modules/smart_ip_ipinfodb_web_service/src/WebServiceUtility.php \Drupal\smart_ip_ipinfodb_web_service\WebServiceUtility::getGeolocation()
  2. 8.3 modules/smart_ip_abstract_web_service/src/WebServiceUtility.php \Drupal\smart_ip_abstract_web_service\WebServiceUtility::getGeolocation()
  3. 8.3 modules/smart_ip_maxmind_geoip2_web_service/src/WebServiceUtility.php \Drupal\smart_ip_maxmind_geoip2_web_service\WebServiceUtility::getGeolocation()
Same name and namespace in other branches
  1. 8.4 modules/smart_ip_maxmind_geoip2_web_service/src/WebServiceUtility.php \Drupal\smart_ip_maxmind_geoip2_web_service\WebServiceUtility::getGeolocation()

Perform HTTP request and decoding the raw Geolocation data returned by Smart IP's data source module web service.

Parameters

string $ipAddress: IP address to query for geolocation.

Return value

array Geolocation data returned by Smart IP's data source module web service.

Overrides WebServiceUtilityInterface::getGeolocation

1 call to WebServiceUtility::getGeolocation()
SmartIpEventSubscriber::processQuery in modules/smart_ip_maxmind_geoip2_web_service/src/EventSubscriber/SmartIpEventSubscriber.php
Act on \Drupal\smart_ip\SmartIp::query() when executed and if selected as Smart IP data source, query the IP address against its database.

File

modules/smart_ip_maxmind_geoip2_web_service/src/WebServiceUtility.php, line 40
Contains \Drupal\smart_ip_maxmind_geoip2_web_service\WebServiceUtility.

Class

WebServiceUtility
Utility methods class wrapper.

Namespace

Drupal\smart_ip_maxmind_geoip2_web_service

Code

public static function getGeolocation($ipAddress = NULL) {
  $url = self::getUrl($ipAddress);
  $json = self::sendRequest($url);
  $data = Json::decode($json);
  return $data;
}