User:DustyBot/Library

Dusty Library provides a set of functions you can use to write your own bot in PHP. The benefits of including this library are its simplicity, functionality, and compatibility. Care has been taken to avoid dependencies on PHP extensions. The library also attempts to emulate the standard PHP function set, as opposed to creating a new framework. It is also intended to be compatible with PHP 4, though this has not been tested. Bots using this library have been run successfully on both EN and Commons.

To download Dusty Library, go to User:DustyBot/dustylib.php, view the page source, and then copy it to disk, avoiding the source tags.

Function reference
Function-level documentation is included in the source file.

Template parsing

 * wp_parse_template($text)
 * wptmpl_create($title)
 * wptmpl_set_arg(&$tmpl, $param, $val)
 * wptmpl_unset_arg(&$tmpl, $param)
 * wptmpl_get_arg($tmpl, $param)
 * wptmpl_has_arg($tmpl, $param)
 * wptmpl_set_title(&$tmpl, $title)
 * wp_build_template($tmpl)
 * wp_find_template($title, $text, $ignore_case = false)

Page editing

 * wp_page_allows_bot($text, $context = null, $messages = null)
 * wp_get_edit_token($title, $context)
 * wp_edit_page($title, $content, $summary, $edtoken, $context, $timestamp = null)

Query

 * wp_get($title, $context = null, &$timestamp = null)
 * wp_get_multiple($titles, $context = null, &$timestamps = null)
 * wp_locate_files($files, $context)
 * wp_get_category_members($category, $context = null)

Session management

 * wp_create_context($maxlag = null, $bot = false, $api_url = null)
 * wp_context_set_query_limit($limit, &$context)
 * wp_login($username, $password, &$context)
 * wp_logout($context)

Other

 * wp_post($post, $context = null)

Example
This basic example overwrites your user page with a list of all the pages in Category:Space colonization. You'll have to supply your own username and password.