Edmund von der Burg > Catalyst-Plugin-Twitter-0.01 > Catalyst::Plugin::Twitter

Download:
Catalyst-Plugin-Twitter-0.01.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.01   Source  

NAME ^

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

SYNOPSIS ^

    # configure your app in MyApp.pm
    MyApp->config(
        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;
    }

DESCRIPTION ^

Twitter (http://www.twitter.com) 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.

METHODS ^

tweet

    $c->tweet('Hello World');
    $c->tweet(
        {   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.

twitter

    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.

PRIVATE METHODS ^

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.

setup

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

finalize

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

_twitter

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

_twitter_queued_tweets

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

_twitter_send_queued_tweets

    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.

SEE ALSO ^

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

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

AUTHOR ^

Edmund von der Burg <evdb@ecclestoad.co.uk>.

http://www.ecclestoad.co.uk/

LICENCE AND COPYRIGHT ^

Copyright (c) 2009, Edmund von der Burg <evdb@ecclestoad.co.uk>. All rights reserved.

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

syntax highlighting: