title: Bad or Invalid Token in Extension with Mediawiki API
body: <p>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, escaping, without +/, etc, doesn't matter.</p>
  
  <p>Code looks like this currently using FauxRequest, with param1/2/3 coming from the parser function I'm creating.</p>
  
  <pre><code>global $wgRequest;
  $token = $token = $wgUser-&gt;editToken();
  
  $params = new FauxRequest( 
      array(
          'action'    =&gt; 'move',
          'from'      =&gt; $param1,
          'to'        =&gt; $param2,
          'format'    =&gt; 'php',
          'reason'    =&gt; $param3,
          'token'     =&gt; $token)
  );
  $api = new ApiMain( $params, true);
  $api-&gt;execute();
  $data = &amp; $api-&gt;getResultData();
  
  
  $output = "moved $param1 to $param2 - $token";
  </code></pre>
  
  <p>also tried the below code using curl instead, which results in bad token as well</p>
  
  <pre><code>global $wgUser;
  $token = $wgUser-&gt;editToken();
  $url = 'http://www.website.com/api.php?';
      $myvars = 'action=move&amp;format=xml&amp;from=' . "$param1" . '&amp;to=' . "$param2" . '&amp;reason=' . "$param3" . '&amp;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_HEADER, 0);
      curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
  
      $response = curl_exec( $ch );
  
  
  $output = "moved $param1 to $param2 - $myvars - $response";
  </code></pre>
  
  <p>Am I missing something in the code, or could I have a setting wrong somewhere?</p>
  
  <p>Any help would be hugely appreciated!</p>