Create a gist now

Instantly share code, notes, and snippets.

require 'rubygems'
require 'feed-normalizer'
require 'open-uri'
require 'twitter'
client = Twitter::REST::Client.new do |config|
config.consumer_key = ENV['TWITTER_CONSUMER_KEY']
config.consumer_secret = ENV['TWITTER_CONSUMER_SECRET']
config.access_token = ENV['TWITTER_ACCESS_TOKEN']
config.access_token_secret = ENV['TWITTER_ACCESS_TOKEN_SECRET']
end
uri_jazz_song_rank = 'https://itunes.apple.com/jp/rss/topsongs/limit=100/genre=11/xml'
feed = FeedNormalizer::FeedNormalizer.parse open(uri_jazz_song_rank)
text = ""
itunes_url = "https://itunes.apple.com/jp/album/rakurai/id887425587?i=887425634"
i = 1
feed.entries.each { |e|
if e.title == "rakurai - YAPANI!"
text = "現在 iTunes Jazz チャート #{i}" + e.title + " #{itunes_url}" + " updated_at:" + e.last_updated.strftime("%Y-%m-%d %H:%M:%S %Z")
client.update(text)
break
end
i+=1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment