#! /usr/local/bin/ruby# coding: utf-8## ========================# Twitter settings# ========================#require'twitter'require'oauth'classTwitterSettings# ConstantsCONS_KEY="<your_consumer_key>"CONS_SEC="<your_consumer_secret>"ACCS_KEY="<your_access_token>"ACCS_SEC="<your_access_token_secret>"T_ZONE="Tokyo"NAME="テストアカウント"URL="http://xxx.yyy.zzz/"LOCATION="Ruby City MATSUE"DESC="これはテストアカウントです。"LN_COLOR="FA743E"PR_BGIMG="/path/to/background.gif"PR_BANNER="/path/to/banner.jpg"PR_IMG="/path/to/profile.png"definitialize@client=Twitter::REST::Client.newdo|config|config.consumer_key=CONS_KEYconfig.consumer_secret=CONS_SECconfig.access_token=ACCS_KEYconfig.access_token_secret=ACCS_SECendend# Main processdefexec# account/settingssettings# account/update_profileupdate_profile# account/update_profile_background_imageupdate_profile_background_image# account/update_profile_bannerupdate_profile_banner# account/update_profile_imageupdate_profile_imagerescue=>e$stderr.puts"[EXCEPTION][#{self.class.name}.#{__method__}] #{e}"exit1endprivate# account/settings# - time_zone: The timezone dates and times should be displayed in for the user.# The timezone must be one of the Rails TimeZone names.defsettingsputs"* account/settings"begin@client.settings({time_zone:T_ZONE})rescue=>eraiseendend# account/update_profile# - name : Maximum of 20 characters# - url : Maximum of 100 characters# - location : Maximum of 30 characters# - description : Maximum of 160 characters# - profile_link_color: (ex: F00 or FA743E)defupdate_profileputs"* account/update_profile"begin@client.update_profile({name:NAME,url:URL,location:LOCATION,description:DESC,profile_link_color:LN_COLOR})rescue=>eraiseendend# account/update_profile_background_image# - The background image for the profile, base64-encoded. Must be a valid GIF,# JPG, or PNG image of less than 800 kilobytes in size. Images with width# larger than 2048 pixels will be forcibly scaled down. The image must be# provided as raw multipart data, not a URL.defupdate_profile_background_imageputs"* account/update_profile_background_image"begin@client.update_profile_background_image(File.open(PR_BGIMG),{tile:true,use:true})rescue=>eraiseendend# account/update_profile_banner# - banner: The Base64-encoded or raw image data being uploaded as the user’s# new profile banner.defupdate_profile_bannerputs"* account/update_profile_banner"begin@client.update_profile_banner(File.open(PR_BANNER))rescue=>eraiseendend# account/update_profile_image# - image: The avatar image for the profile, base64-encoded. Must be a valid GIF,# JPG, or PNG image of less than 700 kilobytes in size. Images with# width larger than 400 pixels will be scaled down. Animated GIFs will# be converted to a static GIF of the first frame, removing the animation.defupdate_profile_imageputs"* account/update_profile_image"begin@client.update_profile_image(File.open(PR_IMG))rescue=>eraiseendendendTwitterSettings.new.exec