The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


Catalyst::Plugin::Twitter - simple sending of tweets from within Catalyst


    # configure your app in
        name    => 'TestApp',
        twitter => {
            username => 'twitter_account_username',
            password => 'twitter_account_password',
    # then somewhere in your controllers:
    sub register : Local {
        my ( $self, $c ) = @_;
        # --- register new user here ---
        # Send a twitter update about the new user
        $c->tweet("We've got another member - $username just registered!");
        return 1;


Twitter ( is a micro-blogging service that lets you post little updates (up to 140 characters) about yourself. It is used for everything from documenting the trivial events of a person's day to providing instantanous updates on road traffic conditions.

This module makes it trivial to send twitter updates (or 'tweets') from within a Catalyst application. It also attempts to do this is an efficient manner.



    $c->tweet('Hello World');
        {   status => 'Hello World',
            # ...any other arguments that Net::Twitter::update accepts

Send out a tweet.

The arguments can either be a simple string (in which case it is used as the 'status') or a hashref of arguments that the Net::Twitter update method would accept.

The tweet is actually added to a queue and is sent at the end of the request. This means that any delay caused by sending the tweet should not stall your request.


    my $net_twitter_object = $c->twitter();

Returns the twitter object. Created the first time it is called and then cached for the duration of the request.

NOTE: If you manipulate the object returned then you may affect where the stored tweets are sent at the end of the request so don't do that. Even calling clone on the object may not do what you expect - see the Net::Twitter documentation for more details. If you must amnipulate it and want to make sure that there are no side effects clear the cache afterwards ($C-_twitter(undef)>) and a new object will be created as required.


You should not ned to use these methods directly - but they are documented here so that you know what they are and what they do.


Check that the required username and password have been provided. Does not check that the username or password are actually valid.


Send any tweets that have been queued up after the request is finalized.


Accessor to the cached Net::Twitter object for this request.


Accessor to the array of tweets that were generated during this request.


    my $count = $c->_twitter_send_queued_tweets;

Method to send all the queued tweets and clear the queue. Returns the number of tweets that were successfully sent.


Net::Twitter for the documentation of the object returned by $c-twitter>.

Text::Variations for ways to make your twitter updates less repetitive.


Edmund von der Burg <>.


Copyright (c) 2009, Edmund von der Burg <>. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.