protected function appendMetaGeolocation($meta, $ip) { // Find country by IPGeolocation if ($apiKey = CMA_Settings::getOption(CMA_Settings::OPTION_GEOLOCIATION_API_KEY)) { $service = new CMA_IPGeolocation(); $service->setKey($apiKey); $response = $service->getCountry($ip); if (!empty($response['countryCode']) and $response['countryCode'] != '-') { $meta[self::META_COUNTRY_CODE] = $response['countryCode']; } if (!empty($response['countryName']) and $response['countryName'] != '-') { $meta[self::META_COUNTRY_NAME] = $response['countryName']; } } return $meta; }
/** * Save post author country by IPGeolocation. * * @return CMA_Thread */ public function checkGeolocation() { if ($apiKey = CMA_Settings::getOption(CMA_Settings::OPTION_GEOLOCIATION_API_KEY)) { $service = new CMA_IPGeolocation(); $service->setKey($apiKey); $response = $service->getCountry($this->getAuthorIP()); if (!empty($response['countryCode']) and $response['countryCode'] != '-') { $this->addPostMeta(array(self::$_meta['authorCountryCode'] => $response['countryCode']), true); } if (!empty($response['countryName']) and $response['countryName'] != '-') { $this->addPostMeta(array(self::$_meta['authorCountryName'] => $response['countryName']), true); } } return $this; }