Operating system code test request...
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- VIP Livecode Opensource Backer
- Posts: 9834
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Operating system code test request...
What does that url provide in a browser?
HTTP is HTTP...
HTTP is HTTP...
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Operating system code test request...
Yes, I'd agree, it may be possible, but I found my answer in 3 minutes of searching. I don't have decades of experience in this language to even guess what the right answer might be.jacque wrote: ↑Mon May 24, 2021 9:13 pmThe info you want isn't in there. Instead it returns the front page of an actual web site at URL "http://infoIP.io".
I tried using "localhost" and variations but I'm still missing something. I'm pretty sure it's possible, I just can't find the right combination.
Yes, http is http, but I would suspect that the page is comprised of a lot of scripting as well which determines from YOUR browsers loading the page what *should* show up in a part of their webpage relevant to your ip's geolocation. I only need the lat. and lon. really, so even what I get back needed to be parsed out, but I think it would be a lot more work to find out where that is posted in an entire webpage of information, than to just get what I need from curl.FourthWorld wrote: ↑Mon May 24, 2021 9:18 pmWhat does that url provide in a browser?
HTTP is HTTP...
-
- VIP Livecode Opensource Backer
- Posts: 9834
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Operating system code test request...
That domain is configured in a way that alters its output based on specific header flags. Their documentation includes a discussion of authentication, suggesting to me (as someone who has only skimmed the page) and unauthenticated use may be a bug prone to closure.
But for now, apparently clearing the user-agent header element will invoke the JSON-format reply, and you can obtain that JSON even more easily by specifying that you want JSON in the the URL (see https://ipinfo.io/developers ):
But for now, apparently clearing the user-agent header element will invoke the JSON-format reply, and you can obtain that JSON even more easily by specifying that you want JSON in the the URL (see https://ipinfo.io/developers ):
Code: Select all
get url "http://ipinfo.io/json"
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Operating system code test request...
Or even more simply:
Code: Select all
get url ("http://api.infoip.io/")
Re: Operating system code test request...
Well, those two certainly work here, thank you both for that. I wonder if that would solve working on Android and iOs (as Jacque asked).
-
- VIP Livecode Opensource Backer
- Posts: 7235
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Operating system code test request...
It does. Then you could use JSONToArray to split it and retrieve the data you need.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Operating system code test request...
Well, thats good to hear heh.
Still, I don't think I would have figured out how to get that on my own, curl is much more natural to me. I would have probably ditched this in frustration long before 3 hours went by.
Actually, since the return is line delimited already, I used lineOffset to pull the loc (which is all I needed) and stuff it into a cust. prop. where it gets pulled to be inserted into an address for the weather page.
Still, I don't think I would have figured out how to get that on my own, curl is much more natural to me. I would have probably ditched this in frustration long before 3 hours went by.
Re: Operating system code test request...
Hi,
looks like they use a geolocation API. This may give good location data on a mobile with calibrated GPS, but will usually give an awfully wrong location for a desktop machine.
It looks for GPS first. If there's none, it will try to find the loc based on charted WIFIs in the area. If this fails too (as it will on most desktop machines) it will return a location estimated by ISP ...
This isn't something you can rely on. Been there, tried that.
What could work, as long as you have address data:
Load "https://www.google.de/maps/place/" & [valid address search string] in a browser. In the source text, search for "https://www.google.de/maps/place/". After the first occurrence you should find your search string again, followed by correct location data.
This doesn't work with "put URL ..." or "put shell("curl ..."), though. But it may work with a revBrowser/ widget in LC, even a hidden one. Never tried such a beast (a browser that doesn't get security updates doesn't qualify as acceptable here).
Have fun!
looks like they use a geolocation API. This may give good location data on a mobile with calibrated GPS, but will usually give an awfully wrong location for a desktop machine.
It looks for GPS first. If there's none, it will try to find the loc based on charted WIFIs in the area. If this fails too (as it will on most desktop machines) it will return a location estimated by ISP ...
This isn't something you can rely on. Been there, tried that.
What could work, as long as you have address data:
Load "https://www.google.de/maps/place/" & [valid address search string] in a browser. In the source text, search for "https://www.google.de/maps/place/". After the first occurrence you should find your search string again, followed by correct location data.
This doesn't work with "put URL ..." or "put shell("curl ..."), though. But it may work with a revBrowser/ widget in LC, even a hidden one. Never tried such a beast (a browser that doesn't get security updates doesn't qualify as acceptable here).
Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!
Re: Operating system code test request...
Understood, but I guess that depends on how accurate your looking to be. This was one method I was thinking of and, if enough replies pile in, would give me some idea of how accurate it might be. I'd say if it is accurate within 50 miles, it is probably accurate enough for it's intended purpose. I'm not exactly turning out a military grade location program heh, just a stupid weather forecast app after seeing so many I've used go wierd. I'm pretty sure it is accurate enough for that.AxWald wrote: ↑Tue May 25, 2021 10:32 amHi,
looks like they use a geolocation API. This may give good location data on a mobile with calibrated GPS, but will usually give an awfully wrong location for a desktop machine.
It looks for GPS first. If there's none, it will try to find the loc based on charted WIFIs in the area. If this fails too (as it will on most desktop machines) it will return a location estimated by ISP ...
This isn't something you can rely on.
Aside from that, as you probably know, I don't use any IDE new enough to have a widget in it, and revBrowser doesn't run on 'nix, so those 2 solutions are no so much for this.
Unfortunately so far, I've had exactly 2 responses that let me know how it's accuracy is, which while highly appreciated, doesn't exactly give me a wide range of information to base a decision on. I may instead wind up just asking for a zipcode from the user, but I'm not going to be getting address information beyond that.
While I am not making this for mobile per se, it will be freely available in it's final form for anyone that wants to use it for whatever. I am targeting desktops and laptops primarily for my own use at this point, the rest of this is just an exercise in making the program more general (I may have to use it in other locations, in other words).
-
- VIP Livecode Opensource Backer
- Posts: 7235
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Operating system code test request...
In that case, note that on Mac the JSON came in without line breaks, so lineOffset wouldn't work there. Alternately, you could replace LF with CR if the OS is Mac.While I am not making this for mobile per se, it will be freely available in it's final form for anyone that wants to use it for whatever.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Operating system code test request...
Now that *is* interesting to know, and it brings up something else I've always wondered. If you replace 'cr' with 'crlf' or 'return' , does that make it work universally across OS'es?
Alternately, I could just go from lineOffset to wordOffset heh.
Alternately, I could just go from lineOffset to wordOffset heh.
-
- Livecode Opensource Backer
- Posts: 9385
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Operating system code test request...
If you replace it with ROTFL is works everywhere, even when there is no computer.
Re: Operating system code test request...
<Chuckling>
-
- VIP Livecode Opensource Backer
- Posts: 7235
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Operating system code test request...
Return (in this usage) and CR are synonyms and will automatically use the native line endings for the OS. CRLF will only work on Windows. LF only works on 'nix (and Android.) If the data you're getting back contains CRLF then it would need to be replaced for OS X.
But In my test, the data came back as a single line with a carriage return at the end. That's why I split it into an array.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Operating system code test request...
Thanks for clarifying that for me, I have to admit I didn't fully understand the dictionary entry on the subject.