NAME

WWW::ImagebinCa::Create - "paste" images to <http://imagebin.ca> from Perl.

SYNOPSIS

use strict;
use warnings;

use WWW::ImagebinCa::Create;

my $bin = WWW::ImagebinCa::Create->new;

$bin->upload( filename => 'pic.jpg' )
    or die "Failed to upload: " . $bin->error;

printf "Upload ID: %s\nPage URI: %s\nDirect image URI: %s\n",
            $bin->upload_id,
            $bin->page_uri,
            $bin->image_uri;

DESCRIPTION

The module provides interface to http://imagebin.ca for uploading new images and including uploader's name, picture description and picture "tags" along with your upload.

CONSTRUCTOR

new

my $bin = WWW::ImagebinCa::Create->new;

my $bin = WWW::ImagebinCa::Create->new(
    timeout => 10,
);

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

Constructs and returns a brand new WWW::ImagebinCa::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 uploading. 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 uploading, 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::ImagebinCa::Create's timeout argument is set to as well as agent argument is set to mimic Firefox.

METHODS

upload

$bin->upload( filename => 'some_pic.jpg' )
    or die "Upload error: " . $bin->error;

my $page_uri = $bin->upload(
        filename    => 'another_pic.bmp',
        name        => 'Pic name',
        tags        => 'Space separated "tags" for the image',
        description => 'Description of the image',
        is_adult    => 1, # is adult content?
) or die "Upload error: " . $bin->error;

Instructs the object to upload a certain image. Takes several arguments, only one of them (filename) is mandatory. If the upload was successful returns a URI to the http://imagebin.ca page with the image but you don't have to store it (see page_uri() method below). If upload failed returns either undef or an empty list depending on the context and the reason for the error will be available via error() method (see below). Possible arguments are as follows:

filename

$bin->upload( filename => 'pic.jpg' );

Mandatory. Takes a scalar representing the filename of the image to upload.

name

$bin->upload( filename => 'pic.jpg', name => 'Kitty meow!' );

Optional. Specifies the name of the image you are uploading. Defaults to: undef (no name).

tags

$bin->upload( filename => 'pic.jpg', tags => 'space separated tags');

Optional. Specifies "tags" for the image you are uploading. Multiple tags are separated by space character. Defaults to: undef (no tags).

description

$bin->upload( filename => 'pic.jpg', description => 'My kitty!' );

Optional. Specifies the description of the image you are uploading. Defaults to: undef (no description).

is_adult

$bin->upload( filename => 'pr0n.jpg', is_adult => 1 );

Optional. Specifies whether or not to flag the image as containing adult content. When set to a true value will mark the image as suitable only for adult humans. When set to a false value will mark the image as suitable for everyone. Defaults to: 0 (suitable for everyone).

error

$bin->upload( filename => 'some_pic.jpg' )
    or die "Upload error: " . $bin->error;

If an error occured during the call to upload() method (see above) it will return either undef or an empty list depending on the context. When that happens you will be able to get the reason for the error via error() method. Takes no arguments, returns human readable error message.

page_uri

print "Yey! You can see your pic on: " . $bin->page_uri;

Must be called after a successful call to upload(). Takes no arguments, returns the URI to the page containing the uploaded image.

image_uri

printf qq|<div style="background: url(%s);">meow</div>\n|,
        $bin->image_uri;

Must be called after a successful call to upload(). Takes no arguments, returns a direct URI to the image you have uploaded. Note that this is not the same as page_uri() (see above). The page_uri() method returns URI to the page containing the image and all the optional information you have provided whereas image_uri() method returns the URI to the image itself. For example, you may wish to use this on on some temporary web page.

upload_id

print "Your upload ID is: " . $bin->upload_id;

Must be called after a successful call to upload(). Takes no arguments, returns the ID of the image you have uploaded. In other words, if page_uri() method (see above) returns http://imagebin.ca/view/GGdpHcV.html the upload_id() method will return GGdpHcV.

AUTHOR

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

BUGS AND CAVEATS

The module relies on HTML parsing, thus it's possible for it to break one day if the author of the site decides to recode it.

According to the bug in HTTP::Request::Common ( http://rt.cpan.org/Public/Bug/Display.html?id=30538 ) it breaks if the filename contains " (double quotes). Avoid those in the images you upload until the bug is resolved.

Please report any bugs or feature requests to bug-www-imagebinca-create at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-ImagebinCa-Create. 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::ImagebinCa::Create

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.