#!/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"); } @include 'HTTP/OAuth/Consumer.php'; if (!class_exists("HTTP_OAuth_Consumer")) { echo "PEAR HTTP_OAuth extension is required\n"; die ("=> yum install php-pear-HTTP_OAuth\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 { $oauth = new HTTP_OAuth_Consumer('ErJZIG5cLkskYjLoSn1g', 'h1Jwk3PmjHOTJwNaHm87fGlKom5zT38xxI7dNjPwI'); $oauth->getRequestToken('http://api.twitter.com/oauth/request_token'); echo "Tocken: ".$oauth->getToken()."\n"; echo "Secret: ".$oauth->getTokenSecret()."\n"; $twitter = new Services_Twitter(); $twitter->setOAuth($oauth); $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"; } ?>