Bridge interface

From Apibot
Revision as of 18:39, 19 October 2014 by Grigor Gatchev (talk | contribs) (Mains -> Core)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This is an interface similar to most other MW bot interfaces (including that of Apibot 0.3x). You can find some examples on how to use it here.

It consists of a single object of the Bridge class.


Constructing the class requires passing to it a Core object:

require_once ( dirname ( __FILE__ ) . '/apibot/settings.php' );
require_once ( dirname ( __FILE__ ) . '/apibot/logins.php' );
require_once ( dirname ( __FILE__ ) . '/apibot/core/core.php' );
require_once ( dirname ( __FILE__ ) . '/apibot/interfaces/bridge/bridge.php' );

$core = new Core ( $login, $settings );

$bridge = new Bridge ( $core );

Alternatively, you can construct a "standalone" Bridge object by passing it directly the login and settings it needs. (In this case, its Core object will be created internally.)

$bridge = new Standalone_Bridge ( $login, $settings );


This object exports the following:


  • $core property - the bot Core object
  • $info property - the Core Info object, shortcutted here for convenience

Query functions

A lot of the Bridge methods are functions that return objects called queries. These objects are of the type Query and can return specific types of information from the wiki - the results from different submodules of the MediaWiki API Query module, or its counterpart in another Apibot backend. (Click here for more info about an Query object.)

Non-Query functions

The rest of the Bridge class are functions that use other API modules or its counterparts for another Apibot backends. With these functions you edit the wiki, perform different actions on it etc.

Extra functions

  • log ( $message, $loglevel = LL_INFO, $preface = "" ) - the standard way to log something in Apibot
  • xfer ( $uri, $params = array(), $files = array() ) - directly fetch and/or submit something over HTTP. (Returns the fetched data, or false if the request failed.)

See also