Skip to content

Instantly share code, notes, and snippets.

@komiyake
Created June 10, 2014 03:36
Show Gist options
  • Save komiyake/26c7bbad292f855987b0 to your computer and use it in GitHub Desktop.
Save komiyake/26c7bbad292f855987b0 to your computer and use it in GitHub Desktop.
草津の現在の天気を表示する
#!/usr/bin/ruby
#encoding:UTF-8
require 'rubygems'
require "twitter"
require 'net/http'
require 'uri'
require 'json'
require 'daemons'
client = Twitter::REST::Client.new do |config|
config.consumer_key = ""
config.consumer_secret = ""
config.access_token = ""
config.access_token_secret = ""
end
uri = URI.parse('http://weather.livedoor.com/forecast/webservice/json/v1?city=250010')
json = Net::HTTP.get(uri)
data = JSON.load(json)
weather = data['forecasts'][0]['telop']
result = "おはよーございます。今日の草津の天気は" + weather + "です( σω-)。о゚"
client.update(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment