Twitter

From EPrints Documentation
Revision as of 15:06, 6 June 2008 by Cjg (talk | contribs)
Jump to: navigation, search

Adding a twitter channel to eprints is dead easy.

First set up a twitter account for your repository.

Add the following to a .pl file in cfg.d/

Add the username and password for the account.

 $c->{eprint_status_change} = sub
 {
        my( $eprint, $old_status, $new_status ) = @_;

        if( $new_status eq "archive" )
        {
                my $twitter_username="username";
                my $twitter_password="password";
                my $cmd1 = "curl -s 'http://is.gd/api.php?longurl=".$eprint->get_url."'";
                my $shorturl = `$cmd1`;
                my $title = $eprint->get_value( "title" );
                $title =~ s/'/\\'/g;
                my $cmd2 = "curl --basic -s --user $twitter_username:$twitter_password --data status='$title - $shorturl' http://twitter.com/statuses/update.xml";
                `$cmd2 &`;
        }
 };

Add your twitter to the list: