Hello, Has anyone used the HostIP API and PHP for Geo targeting? Their site stinks for showing any script examples for setup and I'd really like to try this. The API I'm trying to use is http://api.hostip.info/get_html.php?ip=12.215.42.19 Does anyone have a second to show me the PHP code that would go with this to make that API pull and work? I know that once it works, it should display something like: Country: UNITED STATES (US) City: Sugar Grove, IL I THINK to call it, the code would be along the lines of: <? $country = ''; $IP = $_SERVER['REMOTE_ADDR']; if (!empty($IP)) { $country = file_get_contents('http://api.hostip.info/country.php?ip='.$IP); } ?> PHP: But not sure how to finish it up. Any help would be greatly appreciated!!!! Marceia
Have you tried MaxMind's one? There's a free version of the database, and as it all client side (database stored on server), it instantly looks up IPs to Citys/Countrys, with no delays (also no connection issues). Jay
Yeah, I'm having issues with that one, too. In the maxmind case, I'm generating errors: Warning: fopen(GeoIP.dat) [function.fopen]: failed to open stream: No such file or directory in http://completesources.com/geoip/geoip.inc on line 314 I think the database is getting corrupted when I upload it (in binary). I have a ticket in with my host to see if they will unpack it on the server for me vs me unpacking it on my computer then uploading it. Just to see if that fixes it. In the meantime, I'm trying this hostip to see if I can get anything to work. It's been a very frustrating day.
I use the Maxmind city database webservice for this at http://getmyip.eu/ and a few other sites. It is a paid service but it has never let me down. Maxmind have code examples available for their customers.
I've heard great things about maxmind. I actually JUST found the fix to the maxmind error. The page to call the code apparantly has to be in the same directory as the .dat and the .inc files. That's the problem with free, sometimes, lack of documentation. I really should put out the 50 bucks so I can get better support. LOL. I still wouldn't mind knowing how to call that API just for personal knowledge, but yes, I will probably use the maxmind script.