Ruby on rails Rails Geocoder Gem如何访问Google API?
我知道我们需要使用唯一的API密钥来访问Google Geocoder API。我在应用程序中使用Rails Geocoder Gem,发现它使用Google Geocode API。我找不到任何定义访问Google API的API密钥的配置文件。Geocoder Gem如何访问Google APIRuby on rails Rails Geocoder Gem如何访问Google API?,ruby-on-rails,ruby,google-api,google-geocoder,rails-geocoder,Ruby On Rails,Ruby,Google Api,Google Geocoder,Rails Geocoder,我知道我们需要使用唯一的API密钥来访问Google Geocoder API。我在应用程序中使用Rails Geocoder Gem,发现它使用Google Geocode API。我找不到任何定义访问Google API的API密钥的配置文件。Geocoder Gem如何访问Google API Geocoder.configure( :lookup => :google_premier, :api_key => [ 'GOOGLE_CRYPTO_KEY', 'GOOGL
Geocoder.configure(
:lookup => :google_premier,
:api_key => [ 'GOOGLE_CRYPTO_KEY', 'GOOGLE_CLIENT_ID', 'GOOGLE_CHANNEL' ],
:timeout => 5,
:units => :km,
)
这里还有一个链接:
在
一些常见的配置选项包括:
你应该研究一下这个答案:
它说:
Geocoder仅支持Google Premier帐户的Google api密钥
但是您可以使用客户端框架来实现这一点,而不是将其放在服务器上
几天前我用ruby写过类似的东西,如果有帮助的话:
require 'net/http'
require "resolv-replace.rb"
require 'json'
url = URI("https://maps.googleapis.com/maps/api/geocode/json")
puts "enter country code"
c_code = gets
puts "enter zip code "
zip = gets
url.query= URI.encode_www_form({ address: "#{c_code.chomp}+#{zip.chomp}" })
res = Net::HTTP::get_response(url)
json_data = res.body if res.is_a?(Net::HTTPSuccess)
data = JSON.parse(json_data)
p data
嘿,既然一切都通过了谷歌API云平台,那么为谷歌生成凭证的最新方式是什么?我们是否需要
服务帐户密钥
?我可以找到一个私钥和一个客户端ID,但是“谷歌频道”呢?@CyrilDuchon Doris很抱歉,我已经有一段时间没有处理过这个问题了。你可能需要问另一个问题或尝试谷歌搜索。这就是为什么我尽量避免使用涉及第三方API集成的代码。