public function post_status( $tweet, $name, $pw ) { $request = new RemoteRequest( 'http://twitter.com/statuses/update.xml', 'POST' ); $request->add_header( array( 'Authorization' => 'Basic ' . base64_encode( "{$name}:{$pw}" ) ) ); $request->set_body( 'source=habari&status=' . urlencode( $tweet ) ); $request->execute(); } /** * React to the update of a post status to 'published' * @param Post $post The post object with the status change **/ public function action_post_status_published( $post ) { if ( $post->content_type == Post::type('entry') && Options::get( 'twitter__post_status' ) == '1' ) { $user = User::get_by_id( $post->user_id ); if ( ! empty( $user->info->twitter_name ) && ! empty( $user->info->twitter_pass ) ) { $name = $user->info->twitter_name; $pw = $user->info->twitter_pass; } else { $name = Options::get( 'twitter__username' ); $pw = Options::get( 'twitter__password' ); } $this->post_status( Options::get( 'twitter__prepend' ) . $post->title . ' ' . $post->permalink, $name, $pw ); } return $post; } /* public function action_post_insert_after( $post ) { return $this->action_post_update_status( $post, -1, $post->status ); } */ /** * Add last Twitter status, time, and image to the available template vars * @param Theme $theme The theme that will display the template **/ public function theme_twitter( $theme ) {