Hi !

In my web application, I want to be able to default the user's location (country).  Is this possible and what is the best way to do this ?

I've thought about using the HTTP Request Handler 'GetIP' function to obtain the client IP address and then use a Forge component (any recommendations ?) to obtain the location information from that.  That may hit problems if the user is using a VPN, but I'm not sure there are any foolproof solutions to this requirement.

Any other suggestions ?

Cheers, Richard

Hi,

Not a lowcode answer, sorry.

You can use your IP address to get your 'country', 'city', 'isp' etc...
Just use one of the web-services that provide you with a simple api like http://ip-api.com which provide you a JSON service at http://ip-api.com/json. Simple send a Ajax (or Xhr) request and then parse the JSON to get whatever data you need.

var requestUrl = "http://ip-api.com/json";

$.ajax({
  url: requestUrl,
  type: 'GET',
  success: function(json)
  {
    console.log("My country is: " + json.country);
  },
  error: function(err)
  {
    console.log("Request failed, error= " + err);
  }
});

Hi Richard,


Your question is answered here:

https://www.outsystems.com/forums/discussion/34093/get-location/


Thanks

Jay ar Viluan wrote:

Hi Richard,


Your question is answered here:

https://www.outsystems.com/forums/discussion/34093/get-location/


Thanks


Jay ar Viluan,

I thought as much, but upon experimenting with it, there's a big downside to it. Using that approach you will need the users' permission to determine their location, using something like an IP to Country/Location web API you don't and you still get the information you need (which country are they accessing your app.

Jorge Martins wrote:

Jay ar Viluan wrote:

Hi Richard,


Your question is answered here:

https://www.outsystems.com/forums/discussion/34093/get-location/


Thanks


Jay ar Viluan,

I thought as much, but upon experimenting with it, there's a big downside to it. Using that approach you will need the users' permission to determine their location, using something like an IP to Country/Location web API you don't and you still get the information you need (which country are they accessing your app.

Hi Jorge,

Yes, that is what I thought.  Any recommendations on which Forge component or external API to use to return the country/location for an IP address ?

Cheers, Richard.

I did suggest such and API in my previous post.

I past in a JavaScript example on how to consume it, as that was the only way I have used it.

But of course you can consume the API also on the logic tsb in OutSystems, should be easy.

http://ip-api.com/docs/dns

Hello,

You can take a look at this component: 

Kind regards,
Nuno Verdasca

Hi Nuno,

The OP questioned about web applications, not mobile.

"In my web application, ..."

Cheers.