Ако је потребно да добијете ГЕО-ИП податке користећи макминд сервице - следећа функција ће обавити посао:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | function maxmind_get_data( $ip ) { $query = 'https://geoip.maxmind.com/geoip/v2.1/city/' . $ip; $curl = curl_init($query); curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($curl, CURLOPT_USERPWD, "__YOUR_ID__:__YOUR_KEY__"); //Your credentials goes here curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_ACCEPT_ENCODING, 'application/json'); $resp = curl_exec($curl); if(curl_errno($curl)) { throw new Exception( 'GeoIP request failed with a curl_errno of ' . curl_errno($curl) ); } $result=""; if(!empty($resp)){ $result= json_decode($resp); } return $result; } |
- __ВАША ЛИЧНА КАРТА__ - ваш ИД на макминд сервису
- __ВАШ_КЉУЧ__ - ваш тајни кључ на услузи макминд
Будите сигурни да је то ЦУРЛ је омогућен на вашем хостингу.