I'm trying to make a simple extension that moves a page on my mediawiki site, but whether using curl or FauxRequest, I always get bad token response. Tried urlencoding, not encoding, %2B/, without +/, etc, doesn't matter.  The token shown in the output looks identical to the one when requesting it from the api.  I’m a total programming noob, so could be something simple, but I feel like I’ve been through everything at this point.

Code looks like this currently using FauxRequest, with param1/2/3 coming from the parser function I'm creating.

global $wgUser;
$token = $token = $wgUser->editToken();
 
$params = new FauxRequest( 
    array(
        'action'    => 'move',
        'from'      => “$param1”,
        'to'        => “$param2”,
        'format'    => 'php',
        'reason'    => “$param3”,
        'token'     => “$token”)
);
$api = new ApiMain( $params, true);
$api->execute();
$data = & $api->getResultData();
 
 
$output = "moved $param1 to $param2 - $token";

also tried the below code using curl instead, which results in bad token as well

global $wgUser;
$token = $wgUser->editToken();
$url = 'http://www.wikiocity.com/api.php?';
    $myvars = 'action=move&format=xml&from=' . "$param1" . '&to=' . "$param2" . '&reason=' . "$param3" . '&token=' . urlencode($token);
 
    $ch = curl_init( $url );
    curl_setopt( $ch, CURLOPT_POST, 1);
    curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars);
    curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt( $ch, CURLOPT_USERAGENT, 'MyCoolTool/1.1 (http://example.com/MyCoolTool/; MyCoolTool@example.com) BasedOnSuperLib/1.4');
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
 
    $response = curl_exec( $ch );
 
 
$output = "moved $param1 to $param2 - $myvars - $response";

Am I missing something in the code, or could I have a setting wrong somewhere?

Any help would be hugely appreciated!