Jump to content

ServiceIPGeolocation Module


netcarver
 Share

Recommended Posts

A module that uses the db-ip.com IP Geolocation service to fetch geolocation information when given an IP address. I wrote this quickly to help anyone who might be stuck with the #VATMOSS mess and need a way to geo-locate a customer's IP address.

You will need to register with db-ip.com in order to get an api key but they have a pretty generous daily-query allowance even for the free key (2000 lookups a day.)

post-465-0-81893300-1418675863_thumb.png

Here it is on github.

And in the module repository.

  • Like 13
Link to comment
Share on other sites

Looks like this could come in handy. Just recently wrote a snippet to do the same via ipinfo.io, but db-ip.com seems to be at least cheaper. Do they provide HTTPS support, or is it just plain HTTP? Didn't see that in the docs :)

Also, is there particular reason not to use WireHttp? Mostly out of interest; probably won't matter much in real use.

  • Like 1
Link to comment
Share on other sites

@Teppo

I tried using db-ip.com with HTTPS and it didn't work. I wonder if they reserve that for one of the paid plans. Also, they had an example client class so I took some inspiration from that when calling through to their service and that's why WireHttp wasn't used. Doesn't mean that couldn't happen in a later version.

@Joss

Thanks for the link. I had a very quick peek but didn't see the answer to this: do they offer a live restful service or is it a lookup in a self-hosted DB?

Link to comment
Share on other sites

Minor updates pushed.

@Joss

Thank you for update and the link! I wanted to go for a solution that didn't involve hosting the data myself (either in DB tables or flat files) - but it does leave the site at the mercy of the service's availability. I may investigate a locally-hosted auto-updating version at some point though.

  • Like 2
Link to comment
Share on other sites

Thank you for update and the link! I wanted to go for a solution that didn't involve hosting the data myself (either in DB tables or flat files) - but it does leave the site at the mercy of the service's availability. I may investigate a locally-hosted auto-updating version at some point though.

The gelocation snippet I built earlier was purely on the frontend (JS). Didn't want to host (and keep up to date) the IP database locally, and wanted to avoid extra load and delays server-side. Drawback, of course, is that it might not work (sometimes the user just won't get redirected) and the redirect always happens after the page has been loaded (whether the delay is noticeable or not).

Whatever way you go, there are still issues to deal with :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...