#!/usr/local/bin/ruby $LOAD_PATH << '/home/worris3/lib/' ENV['GEM_HOME'] = '/home/worris3/lib/ruby/gem' require 'rubygems' require 'oauth' require 'cgi' require 'dbm' key="XXXXXXXX" #Consumer Key secret="XXXXXXXX" #Consumer Secret consumer=OAuth::Consumer.new(key, secret, {:site=>"http://twitter.com"}) cgi=CGI.new username=cgi.params['username'][0].to_s title=cgi.params['title'][0].to_s url=cgi.params['url'][0].to_s status=cgi.params['status'][0].to_s comment=cgi.params['comment'][0].to_s token=cgi.params['key'][0].to_s if status=='add' && token!='' secret='' d=DBM.open('oauth_tokens',DBM::READER) secret=d[token] d.close access=OAuth::AccessToken.new(consumer,token,secret) path="/statuses/update.json" line="[B!] #{comment.to_s.gsub(/\[([^\:\[\]]+)\]/,'')} #{url.to_s} #{title.to_s}" line="[B!] #{title.to_s} #{url.to_s}" if comment.to_s.gsub(/\[([^\:\[\]]+)\]/,'')=='' access.post(path, :status => line) print "Content-type: text/html; charset=utf-8\n\nOK" else print "Content-type: text/html; charset=utf-8\n\nNG" end