Post
Topic
Board Micro Earnings
Re: FaucetBOX.com Discussion
by
Kazuldur
on 02/04/2016, 20:35:43 UTC
Hi, freegeoip.net is no longer going to work stable. My question is what alternative can be used? I use geolocation to pay users.
I believe CloudFlare can provide user's location in a custom HTTP header. Not only it will be stable, it'll also be much faster (as you won't need extra http request to external service).
If this doesn't work for you, you can use the other geo-location service I mentioned a page back in this way:
Code:
$countryCode = json_decode(file_get_contents('http://geoip.nekudo.com/api/' . getIP()))->country->code;
I'm not sure but Remote addr won't work with cloudflare. I had the problem and it worked with x-forwarded for.
Remote address return the ip of the cloudflare server.
You may look here

minifrij's example uses getIP() which can handle that (and does that securely). The problem here isn't getting the IP itself, but getting the geographical location of user.