#!/usr/local/bin/ruby
print "Content-type: text/html\n\n"
require "cgi"
cgi = CGI.new
ENV['GEM_HOME']="/home/lightbox/gems"
$LOAD_PATH.push('/home/lightbox/lib')
require 'rubygems'
require 'mechanize'
agent = WWW::Mechanize.new
#twitterにログイン
page = agent.get("http://twitter.com/login")
form = page.forms[1]
form["session[username_or_email]"] = cgi['user2'][0]
form["session[password]"] = cgi['pass2'][0]
page = form.submit
#twitterのページより投稿
form = page.forms[1]
form["status"] = cgi['text2'][0]
result = form.submit
print result.body
|