Graeme McGilvray
asked on
API Location, separating out information
Hi All, I have recently learnt a little about APIs and how awesome they are (using a currency API)
Now I would like to use a GeoLocation API - IPInfoDB
API Link: http://api.ipinfodb.com/v3/ip-country/?key=ACCESSKEY&ip=IPADDRESS
API Output
This is what I got so far (copying from the Currency API):
The End result that all I would like is: the 2 letter country Code
eg:
AU
US
GB
etc
Thanks in advance!
Now I would like to use a GeoLocation API - IPInfoDB
API Link: http://api.ipinfodb.com/v3/ip-country/?key=ACCESSKEY&ip=IPADDRESS
API Output
OK;;74.125.45.100;US;United States
This is what I got so far (copying from the Currency API):
Dim oXMLHTTPLoc
Set oXMLHTTPLoc=CreateObject("MSXML2.ServerXMLHTTP")
LocationAPI="http://api.ipinfodb.com/v3/ip-country/?key=ACCESSKEY&ip="&Request.ServerVariables("REMOTE_ADDR")
oXMLHTTPLoc.Open "POST",LocationAPI, False
oXMLHTTPLoc.Send
If oXMLHTTPLoc.Status = 200 Then
GetTextFromUrl3 = oXMLHTTPLoc.responseText
Arr1 = Split(GetTextFromUrl3, "OK")
Arr2 = Split(Arr1(1), ";")
Arr3 = Split(Arr2(1), " ")
CountryLoc=Arr3(0)
End If
Response.Write("GetTextFromUrl = "&GetTextFromUrl3&"<br><br>Location = "&CountryLoc)
The End result that all I would like is: the 2 letter country Code
eg:
AU
US
GB
etc
Thanks in advance!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hi similarly, can you do a response out for oXMLHTTPLoc.responseText and post it here?
ASKER
Response.Write(oXMLHTTPLoc.responseText)
403 Forbidden
nginx
No idea what nginx is, possibly part of the API
it means the request to the API seems invalid.
can you see what's the value of LocationAPI, and copy and paste it into your browser, see if got any error there?
can you see what's the value of LocationAPI, and copy and paste it into your browser, see if got any error there?
ASKER
That works fine:
OK;;203.161.69.136;AU;Aust ralia
OK;;203.161.69.136;AU;Aust
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Bingo! works a dream! thanks mate! :)
cool man, this seems easier than your another question but at least you got one more issue resolved! cheers
ASKER
haha yeah totally! definately some curly questions! :)
ASKER
GetTextFromUrl =
Location =