flagflag  If you want to see English page, please click "English" Button at Left.
1: 2010-12-21 (火) 18:14:07 s09081 ソース
Line 1: Line 1:
 +*あのね、やり方が邪道とかなんとか文句言うなら代わりに作れ^^; [#ff56b9d7]
 +そういうわけで、RubyのGemを使いやっていきます。
 +**セットアップ [#l9f7649d]
 +簡単アルね、ただRubyを削除して1.9をインストールし、対応するGemをいれる。
 +***Gem [#l3b2a589]
 +GemはApt-getみたいな操作ができる。~
 +つまり、~
 +#Gem install twitter --version=0.9.8~
 +そして的なソースを作るだけ。~
 +~
 +フォロー返し~
 +#!/usr/local/bin/ruby -Ku
 +require "rubygems"
 +require "twitter"
 +require "logger"
 +file = File.open('follow_kaeshi.log', "a+")
 +logger = Logger.new(file, 'daily')
 +#twitter_id = "#your_twitter_id#"
 +#twitter_pw = "#your_twitter_password#"
 +  APP_TOKEN = ['XXXXXXXXXXXXXXX', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'​]
 +  user_atoken = [
 +  '228631234-XXXXXXXXXXXXXXXXXXXXXXXXXXXXX​XXXXXXXXXXXXXXXXXXXX',
 +  'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
 +  ]
 +begin
 +  oauth = Twitter::OAuth.new(*APP_TOKEN)
 +  oauth.authorize_from_access(*user_atoken​)
 +  twit = Twitter::Base.new(oauth)
 +  followers = twit.follower_ids
 +  friends = twit.friend_ids
 +  new_followers = followers - friends
 +  new_followers.each do |id|
 +   twit.friendship_create(id)
 +   sleep 1
 +  end
 +  twit.update "フォローしてた人かえしちゃいましたぁ^^!" if new_followers.length != 0
 +rescue Exception => error
 +  logger.fatal error
 +end
 +
 +時刻表示~
 +
 +#!/usr/local/bin/ruby -Ku
 +  require 'pp'
 +  require 'twitter'
 +t = Time.now
 +array_days = ["日", "月", "火", "水", "木", "金", "土"]
 +day_jp = array_days[t.wday]
 +puts t.strftime("今は %Y年%m月%d日(#{day_jp}) %H時%M分%S秒です")
 +  APP_TOKEN = ['トークン類ね', '類ね']
 +  user_atoken = [
 +  '228123448-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx​xxxxxxxxxxxx',
 +  'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx​xxxxx'
 +  ]
 +  oauth = Twitter::OAuth.new(*APP_TOKEN)
 +  oauth.authorize_from_access(*user_atoken​)
 +  tw = Twitter::Base.new(oauth)
 +  #自分のタイムラインの取得
 +  pp tw.home_timeline
 +  #自分宛てのReplyの取得
 +  pp tw.mentions
 +  #自分宛てのDMの取得
 +  pp tw.direct_messages
 +  #発言する
 +  pp tw.update(t.strftime("%Y年%m月%d日(#{day_jp}) %H時%M分%S秒をお知らせするですぅ~~"))


トップ   新規 ページ一覧 単語検索 最終更新   ヘルプ   最終更新のRSS 1.0 最終更新のRSS 2.0 最終更新のRSS Atom

サイト内 検索

ログイン

ユーザー名:

パスワード:


パスワード紛失
新規登録

サブ メニュー

ミニカレンダー

前月2024年 5月翌月
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
<今日>

オンライン状況

77 人のユーザが現在オンラインです。 (17 人のユーザが xpwiki を参照しています。)

登録ユーザ: 0
ゲスト: 77

もっと...

アクセスカウンタ

今日 : 1896189618961896
昨日 : 1631416314163141631416314
総計 : 2351467123514671235146712351467123514671235146712351467123514671
Powered by XOOPS Cube 2.1© 2001-2006 XOOPS Cube Project
Design by XoopsDesign.com