Created
August 11, 2016 20:02
-
-
Save milothiesen/a48a1feb31dd1aa6365ce811cb89e710 to your computer and use it in GitHub Desktop.
A simple script that gets the user's public IP address and converts it to latitude and longitude coordinates using two APIs. ipify.org and ipapi.co
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A simple script that gets the user's public IP address and converts it to latitude and longitude coordinates using two APIs. ipify.org and ipapi.co | |
require "net/http" | |
ip = Net::HTTP.get(URI("https://api.ipify.org")) | |
puts "My public IP Address is: " + ip | |
convert_ip_to_lat_long = Net::HTTP.get(URI("https://ipapi.co/#{ip}/latlong/")) | |
puts "My lat long is: " + convert_ip_to_lat_long |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment