Created
July 1, 2011 05:36
-
-
Save mager/1057932 to your computer and use it in GitHub Desktop.
Get area code from IP address using SimpleGeo Places & Ruby
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
SimpleGeo::Client.set_credentials(ENV['SIMPLEGEO_KEY'],ENV['SIMPLEGEO_SECRET']) | |
resp = SimpleGeo::Client.geocode_from_ip() | |
options = {:num=>1} | |
place = SimpleGeo::Client.get_places(resp[:query][:latitude], resp[:query][:longitude], options) | |
phone = place[:features][0][:properties][:phone] | |
@area_code = phone[3..-10] # Phone number format: "+1 XXX XXX-XXXX" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment