O4W IP Address Location Lookup (OpenInsight 64-bit)
At 01 AUG 2021 02:59:51PM BrianWick wrote:
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
At 01 AUG 2021 07:11PM Jared Bratu wrote:
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.
At 01 AUG 2021 08:43PM Dave Sigafoos wrote:
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
At 01 AUG 2021 08:46PM Donald Bakke wrote:
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.
At 01 AUG 2021 08:53PM Dave Sigafoos wrote:
Thanks for the quick followup Don … i will look at RTI_JSON
DSig
At 01 AUG 2021 09:31PM Dave Sigafoos wrote:
Anyone know where HTTPClient_Services is in the RTI documents? I can't find it anywhere
thanks Dsig
At 01 AUG 2021 09:39PM Barry Stevens wrote:
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..
At 01 AUG 2021 09:44PM Dave Sigafoos wrote:
Good reason i couldn't find it :)
Thanks
DSig
At 01 AUG 2021 10:09PM Donald Bakke wrote:
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.
At 02 AUG 2021 08:29AM bshumsky wrote:
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
At 02 AUG 2021 09:27AM BrianWick wrote:
hi folks,
Thanks for the plate full of tools to use.
I will see how they work for me.
tx
bri
At 02 AUG 2021 12:45PM BrianWick wrote:
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