NAME

WWW::PastebinCa::Retrieve - retrieve pastes from http://pastebin.ca

SYNOPSIS

use strict;
use warnings;
use WWW::PastebinCa::Retrieve;

my $paster = WWW::PastebinCa::Retrieve->new;

my $content_ref = $paster->retrieve('http://pastebin.ca/930000')
    or die "Failed to retrieve: " . $paster->error;

printf "Posted on %s (%s ago), titled %s\n\n%s\n",
        @$content_ref{ qw(post_date  age  name  content ) };

CONSTRUCTOR

new

my $paster = WWW::PastebinCa::Create->new;

my $paster = WWW::PastebinCa::Create->new(
    timeout => 10,
);

my $paster = WWW::PastebinCa::Create->new(
    ua => LWP::UserAgent->new(
        timeout => 10,
        agent   => 'PasterUA',
    ),
);

Constructs and returns a brand new yummy juicy WWW::PastebinCa::Create object. Takes two arguments, both are optional. Possible arguments are as follows:

timeout

->new( timeout => 10 );

Optional. Specifies the timeout argument of LWP::UserAgent's constructor, which is used for pasting. Defaults to: 30 seconds.

ua

->new( ua => LWP::UserAgent->new( agent => 'Foos!' ) );

Optional. If the timeout argument is not enough for your needs of mutilating the LWP::UserAgent object used for pasting, feel free to specify the ua argument which takes an LWP::UserAgent object as a value. Note: the timeout argument to the constructor will not do anything if you specify the ua argument as well. Defaults to: plain boring default LWP::UserAgent object with timeout argument set to whatever WWW::PastebinCa::Create's timeout argument is set to as well as agent argument is set to mimic Firefox.

METHODS

retrieve

my $content_ref = $paster->retrieve('http://pastebin.ca/930000')
    or die $paster->error;

my $content_ref = $paster->retrieve('930000')
    or die $paster->error;

Instructs the object to retrieve a specified paste. Takes one mandatory argument which can be either a full URI to the paste you want to retrieve or just the paste's ID number. If an error occurs returns either undef or an empty list depending on the context and the reason for the error will be available via error() method. Upon success returns a hashref with the following keys/values:

$VAR1 = {
      'language' => 'Raw',
      'content' => 'select t.terr_id, max(t.start_date) as start_dat',
      'post_date' => 'Wednesday, March 5th, 2008 at 10:31:42pm MST',
      'name' => 'Mine',
      'age' => '17 hrs 43 mins'
};
language
{ 'language' => 'Raw' }

The (computer) language of the paste.

content
{ 'content' => 'select t.terr_id, max(t.start_date) as start_dat' }

The content of the paste.

post_date
{ 'post_date' => 'Wednesday, March 5th, 2008 at 10:31:42pm MST' }

The date when the paste was created

name
{ 'name' => 'Mine' }

Tha name of the poster or the title of the paste.

age
{ 'age' => '17 hrs 43 mins' }

The age of the paste (how long ago it was created).

error

my $content_ref = $paster->retrieve('930000')
    or die $paster->error;

If an error occured during the call to retrieve() method it will return either undef or an empty list depending on the context and the reason for an error will be available via error() method. Takes no arguments, returns human parseable reason for failure.

Note: if the error message contains Failed to parse paste.. $nav{level} == it means that the parser was stopped half-way thru. Please submit a bug with the ID of the paste you've tried to retrieve. Thank you.

results

my $last_retrieve_results = $paster->results;

Must be called after a successfull call to retrieve(). Takes no arguments, returns a hashref which is exactly the same as the return value of retrieve() method.

id

my $paste_id = $paster->id;

Must be called after a successfull call to retrieve(). Takes no arguments, returns a paste ID number of the last retrieved paste irrelevant of whether an ID or a URI was given to retrieve()

uri

my $paste_uri = $paster->uri;

Must be called after a successfull call to retrieve(). Takes no arguments, returns a URI object with the URI pointing to the last retrieved paste irrelevant of whether an ID or a URI was given to retrieve()

response

my $response_obj = $paster->response;

Must be called after a call to retrieve(). Takes no arguments, returns an HTTP::Response object which was obtained while trying to retrieve your paste. You can use it in case you want to thoroughly investigate why the retrieve() might have failed

html_content

my $paste_html = $paster->html_content;

Must be called after a successfull call to retrieve(). Takes no arguments, returns an unparsed HTML content of the paste ID you've specified to retrieve()

timeout

my $ua_timeout = $paster->timeout;

Takes no arguments, returns the value you've specified in the timeout argument to new() method (or its default if you didn't). See new() method above for more information.

ua

my $old_LWP_UA_obj = $paster->ua;

$paster->ua( LWP::UserAgent->new( timeout => 10, agent => 'foos' );

Returns a currently used LWP::UserAgent object used for retrieving pastes. Takes one optional argument which must be an LWP::UserAgent object, and the object you specify will be used in any subsequent calls to retrieve().

AUTHOR

Zoffix Znet, <zoffix at cpan.org> (http://zoffix.com, http://haslayout.net)

BUGS

Please report any bugs or feature requests to bug-www-pastebinca-retrieve at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-PastebinCa-Retrieve. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc WWW::PastebinCa::Retrieve

You can also look for information at:

COPYRIGHT & LICENSE

Copyright 2008 Zoffix Znet, all rights reserved.

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