Difference between revisions of "Twitter"
Line 1: | Line 1: | ||
− | Adding a twitter channel to eprints is dead easy. | + | == Adding a twitter channel to eprints is dead easy. == |
− | First set up a twitter account for your repository. | + | ==== First set up a twitter account for your repository. ==== |
− | Add the following to a .pl file in cfg.d/ | + | Add the following to a new .pl file in cfg.d/ |
+ | |||
+ | You could name this file ''twitter.pl'', for example | ||
Add the username and password for the account. | Add the username and password for the account. | ||
Line 25: | Line 27: | ||
}; | }; | ||
</nowiki></pre> | </nowiki></pre> | ||
+ | |||
+ | ==== Couple of things to look out for: ==== | ||
+ | * Make sure you have CURL installed, as the script invokes this from the command line | ||
+ | * Restart Apache ( /etc/init.d/apache2 force-reload , or similar) | ||
+ | * Then log in and deposit an item to test | ||
+ | |||
Add your twitter to the list: | Add your twitter to the list: | ||
* http://twitter.com/eprintsecs - ECS EPrints, Southampton | * http://twitter.com/eprintsecs - ECS EPrints, Southampton |
Revision as of 19:43, 16 September 2009
Adding a twitter channel to eprints is dead easy.
First set up a twitter account for your repository.
Add the following to a new .pl file in cfg.d/
You could name this file twitter.pl, for example
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 &`; } };
Couple of things to look out for:
- Make sure you have CURL installed, as the script invokes this from the command line
- Restart Apache ( /etc/init.d/apache2 force-reload , or similar)
- Then log in and deposit an item to test
Add your twitter to the list:
- http://twitter.com/eprintsecs - ECS EPrints, Southampton