用Ruby program 做機器人噗

參考這個git
https://github.com/rascov/PlurkOAuth


# Step 1.
gem install oauth json
# get Consumer Key and Consumer Secret @ http://www.plurk.com/PlurkApp/
vim hello.rb
# modify --> plurk = Plurk.new(CONSUMER_KEY, COMSUMER_SECRET)

# Step 2.
ruby hello.rb
# get plurk.get_authorize_url, then request to this URL
# get Code:
# @ terminal console, input "Code"
# get ACCESS_TOKEN and ACCESS_TOKEN_SECRET

# Step 3.
vim hello.rb
# modify plurk.authorize(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
# mark below
#puts plurk.get_authorize_url
#print 'Code: '
#code = gets.chomp!
#access_token = plurk.authorize code

# Step 4.
ruby hello.rb
# get PlurkOAuth

vim hello.rb
# mark below
#plurk.authorize(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
# modify json = plurk.post('/APP/Timeline/plurkAdd', {:content=>'嘴砲歸隊', :qualifier=>'says'})

# Final.
ruby hello.rb
# modify json = plurk.post('/APP/Timeline/plurkAdd', {:content=>'嘴砲歸隊', :qualifier=>'says'})

參考http://blog.jsdan.com/2892
做Crontab

發表留言