NAME
WWW::PhpfiCom::Retrieve - retrieve pastes from http://phpfi.com
SYNOPSIS
use strict;
use warnings;
use WWW::PhpfiCom::Retrieve;
my $paster = WWW::PhpfiCom::Retrieve->new;
my $results_ref = $paster->retrieve('http://phpfi.com/301425')
or die $paster->error;
printf "Paste %s was posted %s ago by %s, it is written in %s "
. "and was viewed %s time(s)\n%s\n",
$paster->uri, @$results_ref{ qw(age name lang hits content) };
DESCRIPTION
The module provides interface to retrieve pastes from http://www.phpfi.com from Perl
CONSTRUCTOR
new
my $paster = WWW::PhpfiCom::Retrieve->new;
my $paster = WWW::PhpfiCom::Retrieve->new(
timeout => 10,
);
my $paster = WWW::PhpfiCom::Retrieve->new(
ua => LWP::UserAgent->new(
timeout => 10,
agent => 'PasterUA',
),
);
Constructs and returns a brand new yummy juicy WWW::PhpfiCom::Retrieve 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 retrieving. 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 retrieving, 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::PhpfiCom::Retrieve
's timeout
argument is set to as well as agent
argument is set to mimic Firefox.
METHODS
retrieve
my $results_ref = $paster->retrieve('http://phpfi.com/301425')
or die $paster->error;
my $results_ref = $paster->retrieve('301425')
or die $paster->error;
Instructs the object to retrieve a paste specified in the argument. Takes one mandatory argument which can be either a full URI to the paste you want to retrieve or just its numeric ID. On failure returns either undef
or an empty list depending on the context and the reason for the error will be available via error()
method. On success returns a hashref with the following keys/values:
$VAR1 = {
'hits' => '0',
'lang' => 'perl',
'content' => '{ test => \'yes\' }',
'name' => 'Zoffix',
'age' => '7 hours and 41 minutes'
};
content
{ 'content' => '{ test => \'yes\' }' }
The content
kew will contain the actual content of the paste.
lang
{ 'lang' => 'perl' }
The lang
key will contain the (computer) language of the paste (as was specified by the poster).
name
{ 'name' => 'Zoffix' }
The name
key will contain the name of the poster who created the paste.
hits
{ 'hits' => '0' }
The hits
key will contain the number of times the paste was viewed.
age
{ 'age' => '7 hours and 41 minutes ago' }
The age
key will contain the "age" of the paste, i.e. how long ago it was created. Note: if the paste is old enough the age
will contain the date/time of the post instead of "foo bar ago".
error
$paster->retrieve('301425')
or die $paster->error;
On failure retrieve()
returns either undef
or an empty list depending on the context and the reason for the error will be available via error()
method. Takes no arguments, returns an error message explaining the failure.
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()
results
my $last_results_ref = $paster->results;
Must be called after a successfull call to retrieve()
. Takes no arguments, returns the exact same hashref the last call to retrieve()
returned. See retrieve()
method 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()
.
SEE ALSO
AUTHOR
Zoffix Znet, <zoffix at cpan.org>
(http://zoffix.com, http://haslayout.net)
BUGS
Please report any bugs or feature requests to bug-www-phpficom-retrieve at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-PhpfiCom-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::PhpfiCom::Retrieve
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW-PhpfiCom-Retrieve
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
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.