示例#1
0
 public static function update_status($str)
 {
     $bitly = new Url_Shortner(array("login" => ORM::factory('setting', 'bitly_login')->value, "key" => ORM::factory('setting', 'bitly_api')->value));
     $str = $bitly->string_shorten($str);
     $twitter = Twitter::instance(ORM::factory('setting', 'twitter_username')->value, ORM::factory('setting', 'twitter_password')->value);
     $twitter->update_status($str);
 }
 public static function instance()
 {
     if (null === self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
示例#3
0
 public function __twitter()
 {
     $twitter_username = ORM::factory('setting', 'twitter_username');
     $twitter_password = ORM::factory('setting', 'twitter_password');
     if (isset($_POST['twitter'])) {
         $twitter_username->value = $_POST['twitter_username'];
         $twitter_username->save();
         $twitter_password->value = $_POST['twitter_password'];
         $twitter_password->save();
     }
     if (isset($_POST['tweet']) && $_POST['tweet'] != '') {
         $twitter = Twitter::instance(ORM::factory('setting', 'twitter_username')->value, ORM::factory('setting', 'twitter_password')->value);
         $twitter->update_status($_POST['tweet']);
         $this->__throw_success('Just tweeted!');
     }
     $html = form::open(NULL);
     $html .= '<p><a href="http://twitter.com/" target="_BLANK">What is twitter?</a></p>';
     $html .= form::hidden('twitter', 'true');
     $html .= form::label('twitter_username', 'Username');
     $html .= form::input('twitter_username', ORM::factory('setting', 'twitter_username')->value, 'class="fullWidth"');
     $html .= form::label('twitter_password', 'Password');
     $html .= form::password('twitter_password', ORM::factory('setting', 'twitter_password')->value, 'class="fullWidth"');
     $html .= form::submit('submit', 'Save', 'class="submit"') . '<p>&nbsp;</p><p>&nbsp;</p>';
     $html .= form::close();
     $twitter = Twitter::instance(ORM::factory('setting', 'twitter_username')->value, ORM::factory('setting', 'twitter_password')->value);
     if (IS_ONLINE && $twitter->account_valid()) {
         $html .= form::open(NULL);
         $html .= form::label('tweet', 'Post a tweet');
         $html .= form::textarea(array('name' => 'tweet', 'class' => 'fullWidth  no-editor', 'style' => 'height:50px;'));
         $html .= form::submit('submit', 'Tweet', 'class="submit"') . '<p>&nbsp;</p><p>&nbsp;</p>';
         $html .= form::close();
         $html .= '<h2>Recent Tweets</h2>';
         $recent_tweets = json_decode($twitter->user_timeline(null, 5));
         foreach ($recent_tweets as $tweet) {
             $html .= '<p>' . date('d-m-y', strtotime($tweet->created_at)) . ' ' . text::auto_link($tweet->text) . '</p>';
         }
         $html .= '<h2>Recent Replies</h2>';
         $recent_tweets = json_decode($twitter->replies());
         $count = 0;
         foreach ($recent_tweets as $tweet) {
             if ($count == 5) {
                 break;
             }
             $html .= '<p>' . date('d-m-y', strtotime($tweet->created_at)) . ' ' . text::auto_link($tweet->text) . '</p>';
             $count++;
         }
     }
     return $html;
 }
示例#4
0
 public function friends_timeline()
 {
     Twitter::instance()->format('json')->friends_timeline(NULL, NULL, 1);
 }