Created
May 12, 2014 00:58
-
-
Save stevelippert/a2091bf6d0d84e93df9f to your computer and use it in GitHub Desktop.
WeatherSTEM API Example in 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
| #!/usr/bin/env ruby | |
| require 'uri' | |
| require 'json' | |
| require 'net/http' | |
| require 'net/https' | |
| uri = URI.parse("https://leonschools.weatherstem.com/api") | |
| https = Net::HTTP.new(uri.host, uri.port) | |
| https.use_ssl = true | |
| https.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
| @vars = { | |
| "api_key" => "cs9ynb6t", | |
| "stations" => ["canopyoaks"] | |
| }.to_json | |
| req = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' => 'application/json'}) | |
| req.body = @vars | |
| response = https.request(req) | |
| puts "Response #{response.code} #{response.message}: #{response.body}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment