(Kidding.)
Your IP. In JSON
61–70 of 72 posts
Re: Your IP. In JSON
#62Some suggestions: Make jsonip.com dual stack IPv4/IPv6 and work for IPv6 addresses too. Return some other useful IP information, such as the PTR, the domain name part of the PTR, and the country code and name. Example: https://grepular.com/ipinfo EDIT: Don't use that URL for your own stuff or I'll block it. I only put it there as an example of how the JSON should be returned. EDIT2: Might be useful if it included the…
This brings up something I'm waffling on. Whats the correct content type for JSON? in your example returning "Content-Type: text/plain; charset=UTF-8" which is nice because FF knows to render it in the browser (good for debugging atleast). But votes on SO seem to indicate it should be "application/json" http://stackoverflow.com/questions/477816/the-right-json-con...
Additionally, if no encoding is specified, UTF-8 should be assumed when dealing with JSON.
Re: Your IP. In JSON
#63Re: Your IP. In JSON
#64Earlier quoted context omitted.
Could anyone list some practical uses ?
I built some WebSocket code that calls back to the server. I can't hardcode the "server" ip address because I want to deploy it to different places at different times. Sometimes I'm working on my laptop, sometimes its running on Amazon EC2, etc. So, with something like this I am able to build my Javascript so it always knows how to get back to the server.
For your use case, relative URLs seem the better solution?
Re: Your IP. In JSON
#65That's clever and useful. Thanks. I've used http://checkip.dyndns.org for this problem for years, but this is an improvement. Checkip: >>> url = urllib2.urlopen("http://checkip.dyndns.org") >>> url.read() ' Current IP Check Current IP Address: 192.168.0.1 \r\n' Details here: http://www.dyndns.com/developers/checkip.html It's not as easy to parse as JSON, but nor is it very difficult. The format has not changed in yea…
You could also use: http://www.whatismyip.com/automation/n09230945.asp
Re: Your IP. In JSON
#66Some suggestions: Make jsonip.com dual stack IPv4/IPv6 and work for IPv6 addresses too. Return some other useful IP information, such as the PTR, the domain name part of the PTR, and the country code and name. Example: https://grepular.com/ipinfo EDIT: Don't use that URL for your own stuff or I'll block it. I only put it there as an example of how the JSON should be returned. EDIT2: Might be useful if it included the…
This brings up something I'm waffling on. Whats the correct content type for JSON? in your example returning "Content-Type: text/plain; charset=UTF-8" which is nice because FF knows to render it in the browser (good for debugging atleast). But votes on SO seem to indicate it should be "application/json" http://stackoverflow.com/questions/477816/the-right-json-con...
Re: Your IP. In JSON
#67That's clever and useful. Thanks. I've used http://checkip.dyndns.org for this problem for years, but this is an improvement. Checkip: >>> url = urllib2.urlopen("http://checkip.dyndns.org") >>> url.read() ' Current IP Check Current IP Address: 192.168.0.1 \r\n' Details here: http://www.dyndns.com/developers/checkip.html It's not as easy to parse as JSON, but nor is it very difficult. The format has not changed in yea…
Documented here: http://dnsomatic.com/wiki/api#detecting_changes
Re: Your IP. In JSON
#68if you need geolocation information through javascript, you can use maxmind's free one: http://j.maxmind.com/app/geoip.js
A simple line-by-line regex loop should be enough to parse this though.
Re: Your IP. In JSON
#69Whoa. I wrote jsonip a few months ago and never expected it to get noticed. What a pleasant surprise! Here's the original post with some usage details. http://news.ycombinator.net/item?id=1896015 This is actually running on node.js. If anyone finds a bug or has some suggestions, email me or leave a tweet @geuis.
Re: Your IP. In JSON
#70Earlier quoted context omitted.
You could also use: http://www.whatismyip.com/automation/n09230945.asp
What a convenient URL to remember.