#!/usr/bin/php yum install php-pear-Console-Getargs\n"); } @include 'Services/Twitter.php'; if (!class_exists("Services_Twitter")) { echo "PEAR Services_Twitter extension is required\n"; die ("=> yum install php-pear-Services_Twitter\n"); } $config = array( "user" => array('short' => 'u', 'max' => 1, 'min' => 1, 'desc' => "User login on server"), "password" => array('short' => 'p', 'max' => 1, 'min' => 1, 'desc' => "Password for user on server"), "status" => array('short' => 's', 'max' => 1, 'min' => 0, 'default' => '', 'desc' => "New status message") ); $args =& Console_Getargs::factory($config); if (PEAR::isError($args)) { echo "twit version " . VERSION . "\n"; if ($args->getCode() === CONSOLE_GETARGS_ERROR_USER) { echo Console_Getargs::getHelp($config, null, $args->getMessage())."\n"; } else if ($args->getCode() === CONSOLE_GETARGS_HELP) { echo Console_Getargs::getHelp($config)."\n"; } exit; } try { $twitter = new Services_Twitter($args->getValue('user'), $args->getValue('password')); $status = $args->getValue('status'); if (empty($status)) { $msg = $twitter->statuses->user_timeline(); if (isset($msg[0]->text)) { echo "Status = " . $msg[0]->text . "\n"; } } else { $msg = $twitter->statuses->update($status); if (isset($msg->text)) { echo "Status = " . $msg->text . "\n"; } } } catch (Services_Twitter_Exception $e) { echo $e->getMessage()."\n"; } ?>