[ Prev ] [ Index ] [ Next ]

Geotargeting

Created Wednesday 26/4/2006

This document describes some simple uses of api.hostip.info, which uses the IP Addresses database for IP address lookup and can be used for geotargeting an ip address. For high-load Geotargeting or IP Address Lookups, a feed of the IP Address database can be used to perserve bandwidth.

1. Simple GET

There is an HTTP oriented API for locating and Geocoding IP addresses. If the http get doesn't include an "?ip=a.b.c.d" parameter, then the ip address of the calling maching is substituted. If the &position=true parameter is present at the end of the URL, then latitude and longitude are also returned. Both HTML and XML formats are supplied.

1.A. Some examples

# locate country for ip address of sending host
bash $ links -dump http://api.hostip.info/country.php
PL

# locate country for specific ip address
bash $ links -dump http://api.hostip.info/country.php?ip=12.215.42.19
US

# country and city for sending host
bash $ links -dump http://api.hostip.info/get_html.php
Country: RZECZPOSPOLITA POLSKA (PL)
City: Warsaw

# country and city for specific ip
bash $ links -dump http://api.hostip.info/get_html.php?ip=12.215.42.19
Country: UNITED STATES (US)
City: Sugar Grove, IL

# country, city, lat+long of sending host
bash $ links -dump http://api.hostip.info/get_html.php?position=true
Country: RZECZPOSPOLITA POLSKA (PL)
City: Warsaw
Latitude: 52.2333

# country, city, lat+long for specific ip
bash $ links -dump http://api.hostip.info/get_html.php?ip=12.215.42.19&position=true
Country: UNITED STATES (US)
City: Sugar Grove, IL
Latitude: 41.7696
Longitude: -88.4588

# xml outout of preceeding example
bash $ links -dump http://api.hostip.info/?ip=12.215.42.19
[use the URL above for an example - XML too long to paste below]

1.B. Some embeded examples

Flag of visitor's location:

<A HREF="http://www.hostip.info">
  <IMG SRC="http://api.hostip.info/flag.php" BORDER="0" ALT="IP Address Lookup"/>
</A>

Flag of any IP address:

<A HREF="http://www.hostip.info">
  <IMG SRC="http://api.hostip.info/flag.php?ip=12.215.42.19" ALT="IP Address Lookup"/>
</A>

1.C. Embedded Applet

The following is designed to be embedded within another HTML page using the OBJECT tag. This reproduces the zoom-in applet, (or an explanatory message with a link to fix, if the IP address lookup is unknown). Which means you can embed the applet in your own site without needing to have the local database and map data (which runs to a few gigabytes...). All you need do is include the OBJECT block below in your HTML. Note, you can also add "?ip=aaa.bbb.ccc.ddd" to the frame.html url below to map a specific IP address.

<OBJECT
  DATA='http://www.hostip.info/map/frame.html'
  TYPE='text/html' BORDER=0
  WIDTH=610 HEIGHT=330 HSPACE=0 VSPACE=0>
</OBJECT>

Stuart Moorfoot © 26 April 2006 foo@bund.com.au


Backlinks: