Talk:API:Calling internally
From MediaWiki.org
[edit] Creating Pages from within the MediaWiki interface
If you are writing an extension that creates pages from within the MediaWiki user interface, you will be bypassing the API entry script, api.php. Therefore, you will need to pass the arguments normally handled by this script.
For example, api.php takes care of passing $wgEnableWriteAPI as the second parameter when you create an object from the ApiMain class; however your script will need to handle this by passing the value yourself:
$api = new ApiMain($parameters, true);
If you don't pass the "true" value as the second parameter, your script will error out, and you'll get a stack trace and error message:
Unexpected non-MediaWiki exception encountered, of type "UsageException" noapiwrite: Editing of this wiki through the API is disabled. Make sure the $wgEnableWriteAPI=true; statement is included in the wiki's LocalSettings.php file
--Lhridley 20:53, 12 July 2009 (UTC)