我正在编写一个脚本,使用google shopping api进行价格跟踪。当我使用curl或网络浏览器点击此网址时,它会加载数据。
但是,当我使用这个ruby脚本时
require "rubygems"
require "net/https"
@url = 'https://www.googleapis.com/shopping/search/v1/public/products?key=AIzaSyCGGKfldgrPQsXAJw5Dbn1M3QWZ9vqVyBQ&country=US&q=digital+camera'
uri = URI.parse @url
http = Net::HTTP.new(uri.host, 443)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.ca_file = File.join(File.dirname(__FILE__), "./cacert.pem")
http.start { http.request_get(uri.path) {|res| print res.body } }
我收到此错误:
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit Exceeded. Please sign up",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit Exceeded. Please sign up"
}
}
我的理论是,错误来自我的ruby代码如何使用https不正确。 cacert.pem来自curl.haxx.se/ca/cacert.pem 要通过https访问api,我需要做什么?
答案 0 :(得分:0)
该错误对我来说看起来很不言自明。每日限额是多少?你有多少请求?