Hello,

I'm trying to perform an API edit call in a maintenance script using this example in MW 1.19.9
http://www.mediawiki.org/wiki/API:Calling_internally


$user = User::newFromId( 1 ); // Using WikiSysiop
$page = WikiPage::newFromID( $id );
$titleText = $page->getTitle()->getPrefixedText();

$text = "...";

global $wgRequest;

$req = new DerivativeRequest(
        $wgRequest,
        array(
        'action' => 'edit',
        'title' => $titleText,
        'text' => $text,
        'token' => $user->editToken(),
        ), true);

$api = new ApiMain( $req, true );
                        
$api->execute();

However, I get this problem:
Unexpected non-MediaWiki exception encountered, of type "UsageException"
badtoken: Invalid token

Any idea what can be wrong?

P.D.: I already use WikiPage::doEdit() successfully.

--
Toni Hermoso Pulido
http://www.cau.cat

_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to