Skip to content

Instantly share code, notes, and snippets.

@gomasy
Created February 25, 2014 08:33
Show Gist options
  • Save gomasy/9205101 to your computer and use it in GitHub Desktop.
Save gomasy/9205101 to your computer and use it in GitHub Desktop.
Twitterアカウントの生存確認bot、cronで走らせてください
#!/usr/bin/ruby
# coding: utf-8
require "net/https"
require "twitter"
target = "" # Target screen name
rest_client = Twitter::REST::Client.new do |config|
config.consumer_key = "" # Your consumer key
config.consumer_secret = "" # Your consumer secret
config.access_token = "" # Your access token
config.access_token_secret = "" # Your access token secret
end
https = Net::HTTP.new("twitter.com", 443)
https.use_ssl = true
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
result = https.head("/#{target}")
if result.class == Net::HTTPOK
rest_client.update("#{Time.now} - #{target}の生存を確認しました")
else
rest_client.update("#{Time.now} - #{target}の死亡を確認しました")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment