You shouldn't use an API when you already have existing data on your machine to do this.
/usr/share/GeoIP/GeoIP.dat
you can use apache2's mod_geoip (apt-get install apache2-mod-geoip or yum install mod_geoip.x86_64)
then, restart apache2. and now
nano /var/www/html/geoiptest.php
PHP Code:
<html>
<body>
<?php
$country_name = apache_note("GEOIP_COUNTRY_NAME");
print "Country: " . $country_name;
?>
</body>
</html>
It worked like a charm for me.
Country: United States
I use (, ; : -) as I please- instead of learning the English language specification: I decided to learn Scheme and Java;
Bookmarks