Created
February 25, 2014 08:33
-
-
Save gomasy/9205101 to your computer and use it in GitHub Desktop.
Twitterアカウントの生存確認bot、cronで走らせてください
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 | |
# 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