WordPress - Perl extension for blah blah blah


WordPress documentation Contained in the WordPress distribution.

Index


Code Index:

NAME

Top

WordPress - Perl extension for blah blah blah

SYNOPSIS

Top

  use WordPress;
  use WordPress;

	my $wp = WordPress->new(

		'http://www.domain.com/xmlrpc.php',
		'admin',
		'pass!'
	);

	# show the available categories
	my @categories = @{ $wp->get_categories };
	print map { "$_\n" } @categories;

	# post in a random category
	$wp->post(

		"Hello, Perl asdf  World!",
		"<h1>Posted via Perl</h1>",
		[ $categories[ rand @categories ] ]
	);

DESCRIPTION

Top

Post to wordpress with the help of perl

EXPORT

None by default.

SEE ALSO

Top

http://www.zoozle.net http://www.zoozle.org http://www.zoozle.biz http://www.sebastian-enger.com/ http://www.zoozle.es

AUTHOR

Top

Sebastian Enger, <bigfish82-A!T-gmail.com>

COPYRIGHT AND LICENSE

Top


WordPress documentation Contained in the WordPress distribution.

#!/usr/bin/perl

package WordPress;

use Carp;
use strict;
use warnings;
use XMLRPC::Lite;

require Exporter;

our @ISA = qw(Exporter);

# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.

# This allows declaration	use WordPress ':all';
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
# will save memory.
our %EXPORT_TAGS = ( 'all' => [ qw(
	
) ] );

our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );

our @EXPORT = qw(
	get_categories
	post
);

our $VERSION = '0.01';


sub new() {

    my ( $class, $proxy, $username, $password ) = @_;

    my $self = {

        server   => XMLRPC::Lite->proxy( $proxy ),
        username => $username,
        password => $password
    };

    bless $self, $class;

    return $self;

}; # sub new() {}


sub get_categories() {

    my $self = shift;

    my $call = $self->{ server }->call(

        'metaWeblog.getCategories',
        1,                              # blogid, ignored
        $self->{ username },
        $self->{ password }
    );
    # $call->fault and croak 'get_categories: ', $call->faultstring;

    my @categories;
    push @categories, $_->{ categoryName } for @{ $call->result };

    return \@categories;

} # sub get_categories() {}


sub post() {

    my ( $self, $title, $description, $categories ) = @_;

    defined $categories or $categories = [];

    my $call = $self->{ server }->call(

        'metaWeblog.newPost',
        1,                              # blogid, ignored
        $self->{ username },
        $self->{ password }, {

            title       => $title,
            description => $description,
            categories  => $categories,
        },
        1                               # publish
    );
    
	# $call->fault and croak 'get_categories: ', $call->faultstring;
	return;

}; # sub post() {

1;

# Preloaded methods go here.

1;
__END__
# Below is stub documentation for your module. You'd better edit it!