SimpleBackpack: PHP wrapper class for Backpack API
I’m sorry, but development of this software has ceased. There won’t be any updates or support for this software in the future.
SimpleBackpack is a simple PHP wrapper class for the Backpack API. It uses curl for API calls and can return SimpleXML objects or the plain xml response. It wraps up almost all available API calls except for two: “Share page with people” and “Unshare yourself from a friend’s page”.
This class was inspired by David Heinemeier Hansson’s ruby wrapper. The curl_exec code originally comes from packagethief’s API wrapper.
Disclaimer
This class comes without any kind of warranty. I hacked this together pretty quickly, so consider it alpha-quality at best. Error handling is abysmal when present at all and i bet there’s some ugly code in there.
Download
v0.1.2: SimpleBackpack.txt
Version History
- 0.1.2 – 05/06/05: added support for the “Move item” and “Email page to yourself” api calls, minor code clean-up
- 0.1.1 – 05/05/21: fixed a bug with “Update title” related to an unexpected linebreak
- 0.1 – 05/05/20: first public release
Example
The SimpleBackpack constructor takes three parameters: your username, your token and an optional parameter specifying whether to return a SimpleXML object or raw XML. The default setting for the third parameter is raw XML.
Here’s a brief example for how to use this class:
<?php
include('SimpleBackpack.php');
$bp = new SimpleBackpack('username', 'token');
$result = $bp->export_backpack();
echo $result;
?>
This instantiates a new SimpleBackpack object, makes an API call to the export function and echos the result.
If you want a SimpleXML object instead of raw XML returned, instantiate the class like this:
<?php
include('SimpleBackpack.php');
$bp = new SimpleBackpack('username', 'token', 'simplexml');
?>
I’m afraid you’ll have to comb through the source for more details.
Would you like to comment?
Tell me what you think on Twitter: @chriwim.