use*_*413 4 api json foursquare
我正在使用foursquare API搜索特定的地点.我使用以下网址:https://api.foursquare.com/v2/venues/venue_id ? oauth_token = Access_token
该网站给出的回应是json.
然后我使用以下代码尝试使用ruby解析此json响应:
require 'rest-open-uri'
require 'json'
url = 'https://api.foursquare.com/v2/venues/venue_id?oauth_token=Access_token'
buffer = open(url, "UserAgent" => "Ruby-Wget").read
result = JSON.parse(buffer)
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误代码:
C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/net/http.rb:678:connect': SSL_con
nect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verif
y failed (OpenSSL::SSL::SSLError)
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/net/http.rb:678:in在连接中的bloc k中来自C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/timeout .rb:44:in timeou
t'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/timeout.rb:89:intimeou t'
此错误代码是否意味着我无法打开此网址,因为它以"https"开头?有什么办法可以用来打开这个url并解析json响应吗?
谢谢!
Mat*_*one 16
这应该工作:
gem install httparty
Run Code Online (Sandbox Code Playgroud)
然后
require 'httparty'
require 'json'
response = HTTParty.get("https://api.foursquare.com/v2/venues/vid",
:query => {:oauth_token => "abc"})
json = JSON.parse(response.body)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19758 次 |
| 最近记录: |