geoPlugin Home

ASP Web Service

The ASP web service allows you to directly program your back-end ASP scripts to deliver dynamic geo-localized pages using the ASP elements provided by geoPlugin.

To access this service, add the following url to a remote include call


http://www.geoplugin.net/asp.gp?ip=xx.xx.xx.xx


Of course, substitute the xx's with your visitor's IP number.

Example output of an ASP query output for your IP address (38.107.191.90) is:

geoplugin_city=@0""@1geoplugin_region=@2""@3geoplugin_areaCode=@4"0"@5geoplugin_dmaCode=@6"0"@7geoplugin_countryCode=@8"US"@9geoplugin_countryName=@10"United States"@11geoplugin_continentCode=@12"NA"@13geoplugin_latitude=@14"38"@15geoplugin_longitude=@16"-97"@17geoplugin_regionCode=@18""@19geoplugin_regionName=@20""@21geoplugin_currencyCode=@22"USD"@23geoplugin_currencySymbol=@24"$"@25geoplugin_currencyConverter=@26"1"@27


An example ASP code snippet making use of this output is:
<%
Set objGetData = Server.CreateObject("Microsoft.XMLHTTP" )
objGetData.Open "GET" , "http://www.geoplugin.net/asp.gp?ip=38.107.191.90", FALSE
objGetData.sEnd
TheData =  objGetData.Responsetext
Set objGetData = Nothing

iCity=InStr(TheData,"@0")
iCityEnd= InStr(TheData,"@1") - iCity
strCity=Mid(TheData,iCity+3,iCityEnd-4)


iRegion=InStr(TheData,"@2")
iRegionEnd= InStr(TheData,"@3") - iRegion
strRegion=Mid(TheData,iRegion+3,iRegionEnd-4)

iAreaCode=InStr(TheData,"@4")
iAreaCodeEnd= InStr(TheData,"@5") - iAreaCode
strAreaCode=Mid(TheData,iAreaCode+3,iAreaCodeEnd-4)

iDmaCode=InStr(TheData,"@6")
iDmaCodeEnd= InStr(TheData,"@7") - iDmaCode
strDmaCode=Mid(TheData,iDmaCode+3,iDmaCodeEnd-4)

iCountryCode=InStr(TheData,"@8")
iCountryCodeEnd= InStr(TheData,"@9") - iCountryCode
strCountryCode=Mid(TheData,iCountryCode+3,iCountryCodeEnd-4)


icountryName=InStr(TheData,"@10")
icountryNameEnd= InStr(TheData,"@11") - icountryName
strcountryName=Mid(TheData,icountryName+4,icountryNameEnd-5)

icontinentCode=InStr(TheData,"@12")
icontinentCodeEnd= InStr(TheData,"@13") - icontinentCode
strcontinentCode=Mid(TheData,icontinentCode+4,icontinentCodeEnd-5)

ilatitude=InStr(TheData,"@14")
ilatitudeEnd= InStr(TheData,"@15") - ilatitude
strlatitude=Mid(TheData,ilatitude+4,ilatitudeEnd-5)

ilongitude=InStr(TheData,"@16")
ilongitudeEnd= InStr(TheData,"@17") - ilongitude
strlongitude=Mid(TheData,ilongitude+4,ilongitudeEnd-5)


icurrencyCode=InStr(TheData,"@18")
icurrencyCodeEnd= InStr(TheData,"@19") - icurrencyCode
strcurrencyCode=Mid(TheData,icurrencyCode+4,icurrencyCodeEnd-5)

icurrencySymbol=InStr(TheData,"@20")
icurrencySymbolEnd= InStr(TheData,"@21") - icurrencySymbol
strcurrencySymbol=Mid(TheData,icurrencySymbol+4,icurrencySymbolEnd-5)

icurrencyConverter=InStr(TheData,"@22")
icurrencyConverterEnd= InStr(TheData,"@23") - icurrencyConverter
strcurrencyConverter=Mid(TheData,icurrencyConverter+4,icurrencyConverterEnd-5)

%>
Many thanks to Savas for getting the ASP webservice working!


ASP Currency Converter

The “geoplugin_currencyConverter” element is the conversion rate for the currency converter base currency.
Like all calls to any of geoPlugin's web services, the default base_currency is USD ($US).
Thus, if your base currency is NOT $US, then you must add the variable base_currency=XXX to the call to geoplugin.net
eg

http://www.geoplugin.net/asp.gp?base_currency=EUR

Now the geoplugin_currencyConverter element will output the exchange rate of one Euro for your visitor.


The base_currency value must be a valid ISO 4217 3-letter code.





See also