Is anybody using an API (or downloaded DB) lookup of Geo location IP addresses.
I see a number of them by googling
"where is ip address located"
but if someone has already an O4W API - or a website to download an entire DB of IP Geolocation info
please let me know
tx
bri
Here is a code snippet of using IPStack's REST API to lookup the GeoLocation.
Declare Function HTTPClient_Services Declare Subroutine HTTPClient_Services // Get your account API key from https://ipstack.com/ APIKey = 'PUT YOUR KEY HERE' // What IP do you want to lookup? IPToCheck = '8.8.8.8' URL = 'http://api.ipstack.com/' : IPToCheck : '?access_key=' : APIKey Response = HTTPClient_Services('SendHTTPRequest', 'GET', URL) ResponseCode = HTTPClient_Services('GetResponseStatusCode') //Dump the raw response somewhere //OSWrite Response To 'C:\Temp\test.json' If ResponseCode EQ 200 then // Valid response ParseResult = SRP_JSON(ResponseObj, 'Parse', Response) If ParseResult EQ '' then // We have a valid JSON Response APICallSuccess = SRP_JSON(ResponseObj, 'GetValue', 'success', 'boolean') If APICallSuccess ne False$ then // The request is successful City = SRP_JSON(ResponseObj, 'GetValue', 'city') State = SRP_JSON(ResponseObj, 'GetValue', 'region_code') Call msg(@WINDOW, 'How is the weather in ' : City : ',' : State : '?') end else // The request failed, why? ErrorMsg = SRP_JSON(ResponseObj,'GetValue', 'error.info') Call msg(@WINDOW, 'Error: ' : ErrorMsg) end end Else // The HTTP Call failed call msg(@WINDOW, 'Error, the HTTP call returned an unhandled response') end End else // Non-sucess HTTP response code ResponsePhrase = HTTPClient_Services('GetResponseStatusPhrase') call msg(@WINDOW, 'HTTP Call failed response ' : ResponseCode : ' ' : ResponsePhrase) endIf you are looking for something more exact you'll need to use the browser location API.
Jared … i looked on the srp site for dev tools to see how much SRP_JSON is … but there was no mention anywhere about developer tools. Are they still available?
DSig
Jared … i looked on the srp site for dev tools to see how much SRP_JSON is … but there was no mention anywhere about developer tools. Are they still available?
DSig
David - SRP_JSON is built into our free SRP Utilities library. However, we wrote that back with RTI_JSON was based on a script engine and we wanted something that was more performant. RTI_JSON in OI 10 is very capable and the syntax is fairly similar. Therefore, unless you have already installed SRP Utilities for other reasons, you might want to just use RTI_JSON.
Thanks for the quick followup Don … i will look at RTI_JSON
DSig
Anyone know where HTTPClient_Services is in the RTI documents? I can't find it anywhere
thanks Dsig
Anyone know where HTTPClient_Services is in the RTI documents? I can't find it anywhere
thanks Dsig
It is a SRP ssp part of the HTTP_Services framework..
Good reason i couldn't find it :)
Thanks
DSig
Good reason i couldn't find it :)
Thanks
DSig
The native OI equivelent would be the OLE_GetWebPage function, which works in both OI 9 and OI 10. OI 10 may have introduced a better replacement, but I don't recall seeing one.
Is anybody using an API (or downloaded DB) lookup of Geo location IP addresses.
I see a number of them by googling
"where is ip address located"
but if someone has already an O4W API - or a website to download an entire DB of IP Geolocation info
please let me know
tx
bri
Hi, Brian. I'm assuming you're not really interested in finding out where any generic IP address is located, rather you're trying to get the client's browser to tell you where THEY are coming from - is that correct?
It that is what you're looking for, as was mentioned by Jared (I think), there is a way to ask the browser to tell you where they are, but this is subject to the user's settings - they can disable the functionality entirely, or be prompted as to whether they will allow it on a case by case basis, so it _might_ (or might not) work in any specific case.
There is an O4WGPSCoordinatesOptions API call that you can apply to a textbox (or a section (div), or a hidden textbox), that will get the coordinates of the browser IF it is allowed. The parameters of the call are:
O4WGPSCoordinatesOptions(typeOption, mapHeight)
where typeOption is one of the following:
"lat"
"long"
"latxlong"
"map"
and, if type is map, then mapHeight is how big to draw the map. Note that "map" only applies if you are using this with a section, and the others only apply to textbox or o4wstore (hidden textbox).
Hope that helps,
- Bryan Shumsky
hi folks,
Thanks for the plate full of tools to use.
I will see how they work for me.
tx
bri
Hi Folks -
Tx Jared per your IPStack.com suggestion - looks like I need a pay subscription to get SSL pages.
In the mean time I may need a bit more direction on RTI_JSON. O4W_GetWebpage delivers the following:
{"success":false,"error":{"code":105,"type":"https_access_restricted","info":"Access Restricted - Your current Subscription Plan does not support HTTPS Encryption."}}
WebPage1 = OLE_GetWebPage(URL1,"GET","","","","")oRec = RTI_JSON( WebPage1, 'Parse')Success1 = RTI_JSON(oRec, 'GetValue', "success")Error1 = RTI_JSON(oRec, 'GetValue', "error")oRec1 = RTI_JSON( error1, 'Parse')Code1 = RTI_JSON(oRec1, 'GetValue', "code")Type1 = RTI_JSON(oRec1, 'GetValue', "type")Info1 = RTI_JSON(oRec1, 'GetValue', "info")This all works correctly - very cool stuff.
Is it up to me to determine is "error1" needs to be parsed by seeing if the value starts with a '{'
or does RTI_JSON have a way of doing it automatically (i.e. embedded {} fields, like code, type, info within error) ?
tx
Bri