Skip to content

Instantly share code, notes, and snippets.

@designershao
Created October 28, 2013 06:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save designershao/7192220 to your computer and use it in GitHub Desktop.
Save designershao/7192220 to your computer and use it in GitHub Desktop.
Get the location through baidu map`s api in ruby.
require 'net/http'
require 'json'
url = "http://api.map.baidu.com/geocoder?address=address_you_find&output=json&key=you_secret_key&city=city_you_find"
uri = URI.escape(url)
json_str = Net::HTTP.get(URI(uri))
value = JSON.parse(json_str)
puts value["result"]["location"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment