I am trying to use ip-api.com (IP Geolocation) to retrieve usage limit.
1st - I've managed to use the api with php, but they don't give the usage limit (max 45/minute) in the response format. They say that that information is returned in the HTTP header.
2nd - So I opened chrome developer network to see if I find the variables (X-R1 and X-Ttl) or whatever they called in the HTTP header but I don't see them there.
3rd - What I've managed to do is using php function (get_headers($url)), it works fine but when ever the script is run it counts as 2 requests for the API, so the usage limits always counts as 2.
How do I find them in the 2nd step or with some php function so I don't have to make another request like i did in the 3rd?
<?php
//1st request
function getClientIp(){
if(!empty($_SERVER['HTTP_CLIENT_IP'])){
//ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
}elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
//ip pass from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
$clientIp = getClientIp();
$query = @unserialize(file_get_contents('http://ip-api.com/php/'.$clientIp));
if ($query['status'] == 'success'){
echo $query['city'];
echo '<br>';
echo $query['query'];
};
//2nd Request
echo '<br><br>';
$url = 'http://ip-api.com/php/'.$clientIp;
//print_r(get_headers($url));
print_r(get_headers($url, 1)['X-Rl']);