The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::Backpack - Perl extension for interfacing with Backpack.

SYNOPSIS

    use strict; use warnings;
    use Net::Backpack;

    my $bp = Net::Backpack(
        user  => $your_backpack_username,
        token => $your_backpack_api_token,
        ssl   => $use_ssl
    );

    # Fill out a Perl data structure with information about your Backspace pages.
    my $std_pages = $bp->list_all_pages;

    # Alternatively get the same information in XML format
    my $xml_pages = $bp->list_all_pages(xml => 1);

    # Create a new page
    my $page = $bp->create_page(
        title       => 'A test page',
        description => 'Created with the Backpack API'
    );

    # Get the id of the new page
    my $page_id = $page->{page}{id};

    # Get details of the new page (in XML format)
    my $page_xml = $bp->show_page(id => $page->{page}{id});

    # Rename the page
    $bp->update_title(
        id    => $page_id,
        title => 'A new title'
    );

    # Change the body
    $bp->update_description(
        id          => $page_id,
        description => 'Something new'
    );

    # Remove the page
    $bp->destroy_page(id => $page_id);

DESCRIPTION

Net::Backpack provides a thin Perl wrapper around the Backpack API. Currently it only implements the parts of the API that manipulate Backpack pages. Future releases will increase the coverage.

Getting Started

In order to use the Backpack API, you'll need to have a Backpack API token.And in order to get one of those, you'll need a Backpack account.But then again, the API will be pretty useless to you if you don't have a Backpack account to manipulate with it.

You can get a Backpack account from here.

Backback API

The Backpack API is based on XML over HTTP. You send an XML message over HTTP to the Backpack server and the server sends a response to you which is also in XML. The format of the various XML requests and responses are defined here.

This module removes the need to deal with any XML.You create an object to talk to the Backpack server and call methods on that object to manipulate your Backpage pages. The values returned from Backpack are converted to Perl data structures before being handed back to you (although it is also possible to get back the raw XML).

IMPORTANT NOTE

Net::Backpack uses XML::Simple to parse the data that is returned from Backpack.From version 1.10 of Net::Backpack has changed.By default we now pass the parameter ForceArray => 1 to XML::Simple. This will change the Perl data structure returned by most calls.

To get the old behaviour back, you can pass the parameter forcearray => 0 to the new function.

METHODS

new(%params)

Creates a new Net::Backpack object. All communication with the Backpack server is made through this object.

Takes two mandatory arguments,your Backpack API token and your Backpack username. Returns the new Net:Backpack object.

There is also an optional parameter, forcearray. This controls the value of the ForceArray parameter that is used by XML::Simple. The default value is 1.

If the ssl parameter is provided, then communication will take place over SSL. This is required for Plus and Premium accounts.

    my $bp = Net::Backpack->new(
        token      => $token,
        user       => $user,
        forcearray => 0,
        ssl        => 0
    );

list_all_pages(%params)

Get a list of all of your Backpack pages.Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

    my $bp = Net::Backpack->new(
        token      => $token,
        user       => $user,
        forcearray => 0,
        ssl        => 0
    );

    $pages = $bp->list_all_pages(xml => 1);

create_page(%param)

Create a new Backpack page with the given title and (optional) description.Returns a Perl data structure unless the xml parameter is true,in which case it returns the raw XML as returned by the Backpack server.

    my $bp = Net::Backpack->new(
        token      => $token,
        user       => $user,
        forcearray => 0,
        ssl        => 0
    );

    my $page = $bp->create_page(
        title       => $title,
        description => $desc,
        xml         => 1
    );

$rc = $bp->show_page(id => $id, [xml => 1]);

Get details of the Backpack page with the given id. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$rc = $bp->destroy_page(id => $id, [xml => 1]);

Delete the Backpack page with the given id. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$rc = $bp->update_title(id => $id, title => $title, [xml => 1]);

Update the title of the given Backpack page. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$rc = $bp->update_body(id => $id, description => $desc, [xml => 1]);

Update the description of the given Backpack page. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$page = $bp->duplicate_page(id => $id, [xml => 1]);

Create a duplicate of the given Backpack page. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

Link one Backpack page to another. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

Unlink one Backpack page from another. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$rc = $bp->share_page(id => $id, people => \@people, [ xml => 1 ]);

Share a given Backpack page with a list of other people. The parameter 'people' is a list of email addresses of the people you wish to share the page with.

$rc = $bp->make_page_public(id => $id, public => $public, [ xml => 1 ]);

Make a given Backpage page public or private. The parameter 'public' is a boolean flag indicating whether the page should be made public or private

$rc = $bp->unshare_friend_page(id => $id, [ xml => 1 ]);

Unshare yourself from a friend's page.

$rc = $bp->email_page(id => $id, [ xml => 1 ]);

Email a page to yourself.

$items = $bp->list_all_items(page_id => $page_id, [xml => 1]);

Get a list of all of your Backpack checklist items. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$item = $bp->create_item(page_id => $page_id, item => $item, [xml => 1]);

Create a Backpack checklist item given a page id and some item content. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$item = $bp->update_item(page_id => $page_id, item => $item, [xml => 1] id => $item_id);

Updates a Backpack checklist item given a page id, item id, and new content. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$response = $bp->toggle_item(page_id => $page_id, id => $item_id, [xml => 1]);

Toggles a Backpack checklist item given a page id and an item id. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$response = $bp->destroy_item(page_id => $page_id, id => $item_id, [xml => 1]);

Destroys a Backpack checklist item given a page id and an item id. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$response = $bp->move_item(page_id => $page_id, id => $item_id, direction => $direction, [xml => 1]);

Modifies the location in the list of a Backpack checklist item. Requires a page id, a direction and an item id. Valid values for direction are "move_lower", "move_higher", "move_to_top", and "move_to_bottom". Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$notes = $bp->list_all_notes(page_id => $page_id, [xml => 1]);

Get a list of all of your Backpack notes. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$note = $bp->create_note(page_id => $page_id, title => $title, body => $body, [xml => 1]);

Create a Backpack note given a page id and some content. Title is required, body is optional. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$note = $bp->update_note(page_id => $page_id, id => $note_id, [xml => 1] title => $title, body => $body);

Updates a Backpack note given a page id, note id, and new content. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$response = $bp->destroy_note(page_id => $page_id, id => $note_id, [xml => 1]);

Destroys a Backpack note given a page id and an note id. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$pages = $bp->get_tag_pages(page_id => $id, [ xml => 1 ]);

Retrieve all the pages associated with a particular tag id. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$response = $bp->set_page_tags(page_id => $id, tags => \@tags, [ xml => 1 ]);

Set the tags for a given Backpack page. This method overwrites all tags for the page. An empty set of tags serves to remove all the tags for the page. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

This is currently returning true, and though it seems to create and submit a valid request, the tags are not being updated.

$reminders = $bp->upcoming_reminders([ xml => 1 ]);

Gets the upcoming Backpack reminders for an account, in the time zone specified per the account's settings. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$reminder = $bp->create_reminder(content => $reminder, [xml => 1], [remind_at => $remind_at]);

Create a Backpack reminder given some reminder content. The content takes fuzzy date/times like "+30 Do foo and bar" to set the reminder for 30 minutes from now. Optionally, specify a date in a relatively parseable date format and use the remind_at parameter instead. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$reminder = $bp->update_reminder(id => $reminder_id, [content => $reminder], [xml => 1], [remind_at => $remind_at);

Update a Backpack reminder given a reminder id. The content takes fuzzy date/times like "+30 Do foo and bar" to set the reminder for 30 minutes from now. Optionally, specify a date in a relatively parseable date format and use the remind_at parameter instead. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$response = $bp->destroy_reminder( id => $reminder_id, [xml => 1]);

Destroys a Backpack reminder given a reminder id. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$emails = $bp->list_all_emails(page_id => $page_id, [xml => 1]);

Get a list of all of your Backpack email items for a page. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$email = $bp->show_email(page_id => $page_id, id => $reminder_id, [xml => 1]);

Returns a Backpack email item given a page id and an email id. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$response = $bp->destroy_email(page_id => $page_id, id => $reminder_id, [xml => 1]);

Destroys a Backpack email item for a page given a page id and an email id. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$exported_bp = $bp->export([xml => 1]);

Exports an account's entire Backpack. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$lists = $bp->list_all_lists(page_id => $page_id, [xml => 1]);

Get a list of *all* of your Backpack checklists for a specific page. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$list = $bp->list_this_list(page_id => $page_id, list_id => $list_id, [xml => 1]);

Get details of a specific list with the given list_id on a specific Backpack page with the given page_id. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$list = $bp->create_list(page_id => $page_id, title => $title, [xml => 1]);

Create a new Backpack checklist given a page id and a list title. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$list = $bp->update_list(page_id => $page_id, list_id => $list_id, title => $title, [xml => 1]);

Update the title of a specific list with the given list_id on a specific Backpack page with the given page_id. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$list = $bp->destroy_list(page_id => $page_id, list_id => $list_id, [xml => 1]);

Destroy a specific list with the given list_id on a specific Backpack page with the given page_id. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

$list = $bp->create_list_item(page_id => $page_id, list_id => $list_id, item = $item, [xml => 1]);

Create an item on a specific list with the given list_id on a specific Backpack page with the given page_id. This differs from the usual "create_item" function in that you can specify which list on a page you want to add the item to. Returns a Perl data structure unless the xml parameter is true, in which case it returns the raw XML as returned by the Backpack server.

AUTHOR

Dave Cross <dave@dave@mag-sol.com>

Please feel free to email me to tell me how you are using the module.

Lots of stuff implemented by neshura when I was being too tardy!

Currently maintained by Mohammad S Anwar, <mohammad.anwar at yahoo.com>

REPOSITORY

https://github.com/manwar/net-backpack

BUGS

Please report bugs by email to <bug-Net-Backpack@rt.cpan.org>.

LICENSE AND COPYRIGHT

Copyright (c) 2005, Dave Cross. All Rights Reserved.

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

SEE ALSO

http://backpackit.com/, http://backpackit.com/api