WWW::Sitebase::Poster is a base Perl class for web site posting routines.
SYNOPSIS
package MyPostingModule;
use WWW::Sitebase::Poster -Base;
# Define your options
sub default_options {
my $options = super;
$options->{cache_file} = { default => 'mypostingmodule' }; # (VERY IMPORTANT)
$options->{my_option} = 0; # 0 = not required. 1 means required.
$options->{my_option} = { default => 'mydefault' }; # Sets a default for your option.
# Some common example options, say for posting messages or comments:
$options->{subject} = 1; # Require subject
$options->{message} = 1; # Require a message
return $options;
}
# Add accessors if you like (usually a good idea)
# (Poster.pm already gives you the cache_file accessor).
field 'my_option';
field 'subject';
field 'message';
# Define your send_post method (see examples below)
sub send_post {
my ( $friend_id ) = @_;
$result = $self->browser->do_something( $friend_id, $other_value );
# ... Do anything else you need ...
return $result; # $result must be P, R, F, or undef. (Pass, Retry, Fail, or stop)
}
----------------
Then you or others can write a script that uses your module.
#!/usr/bin/perl -w
use MyPostingModule;
use WWW::Myspace;
my @friend_list = &fancy_friend_gathering_routine;
my $poster = new MyPostingModule(
browser => new WWW::Myspace, # Note, this'll prompt for username/password
friend_ids => @friend_list,
subject => 'hi there!',
message => 'I'm writing you a message!',
noisy => 1,
interactive => 1,
);
$poster->post;
This is a base class for modules that need to post things and remember to whom they've posted. If you're writing a new module that needs to send something and remember stuff about it, you'll want to look at this module. It gives you all sorts of neat tools, like write_log and read_log to remember what you did, and it automatically parses all your arguments right in the new method, and can even read them from a config file in CFG or YAML format. All the "new" method stuff it just inherits from WWW::Sitebase, so look there for more info.
The cache_file is where write_log and read_log write and read their data.
You MUST set the cache_file default to something specific to your module. This will be used by the cache_file method to return (and create if needed) the default cache file for your module. Make sure it's unique to "Poster" modules. (Hint: name it after your module). Your default filename will be placed in the value returned by $self->cache_dir (.www-poster by default), so don't specify a path. If you're writing a WWW::Myspace module, you should override cache_dir. See "cache_dir" below.
This module itself is a subclass of WWW::Sitebase, so it inherits "new", default_options, and a few other methods from there. Be sure to read up on WWW::Sitebase if you're not familiar with it, as your class will magically inherit those methods too.
Product's homepage
Requirements:
· Perl