Created
June 10, 2014 03:36
-
-
Save komiyake/26c7bbad292f855987b0 to your computer and use it in GitHub Desktop.
草津の現在の天気を表示する
This file contains 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/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