夢見るポテト

色々きになったことを書いてこうと思う

Twitterトレンド(日本の)を表示するRubyプログラム

こちらをRubyからTwitter APIを呼び出してツイッターのトレンド情報を取得するプログラム - halcv's blog
ほぼ丸々コピーしてやっと出来た(T_T)
基礎からやっていかないと無理かなぁ

一応コードを載せとこう

#-*-codeing: utf-8-*-

require 'open-uri'
require 'rubygems'
require 'json'
require 'timeout'

json = nil

begin
	timeout(10){
url = "https://api.twitter.com/1/trends/1118370.json"
puts json  = URI(url).read
}

else
hash = JSON.parse(json)
	
	hash[0]["trends"].each{|trends|
		name = trends["name"]
		print(name,"\n")
}
end