Thread:Project:Support desk/api action=move badtoken error

Hi I get a badtoken error when trying to use api to move a page to another page. Here is the code that I am using:

<?php /** * Configuration * - */ // Start session session_start; // Login $app['username'] = "abc"; $app['password'] = "cheng"; // Version $app["version"] = "0.0.1-dev"; // Last modified date_default_timezone_set("UTC"); $app["lastmod"] = date("Y-m-d H:i", getlastmod). " UTC"; // Example: 2010-04-15 18:09 UTC // User-Agent used for loading external resources $app["useragent"] = "My First Tool ". $app["version"]. " (LastModified: " . $app["lastmod"] . ") Contact: myfirsttool (at) example (.) com"; // Cookie file for the session $app["cookiefile"] = tempnam("/tmp", "CURLCOOKIE"); // cURL to avoid repeating ourselfs $app["curloptions"] = array(               CURLOPT_COOKIEFILE => $app["cookiefile"],                CURLOPT_COOKIEJAR => $app["cookiefile"],                CURLOPT_RETURNTRANSFER => 1,                CURLOPT_USERAGENT => $app["useragent"],                CURLOPT_POST => true        ); $app["apiURL"] = "http://138.85.252.123/mediawiki/api.php"; /** * Login * - */ // Info: http://www.mediawiki.org/wiki/API:Login $postdata = "action=login&format=php&lgname=". $app["username"]. "&lgpassword=". $app["password"]; $token=""; $ch = curl_init; curl_setopt_array($ch, $app["curloptions"]); curl_setopt($ch, CURLOPT_URL, $app["apiURL"]); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); $result = unserialize(curl_exec($ch)); if(curl_errno($ch)){ $curl_error = "Error 003: ". curl_error($ch); } curl_close($ch); //print_r($result);//die;//DEBUG $_SESSION["logintoken"]=""; // Basic error check + Confirm token if ($curl_error){ $domain_error = $curl_error; } else if ($result["login"]["result"] == "NeedToken") { if (!empty($result["login"]["token"])) { $_SESSION["logintoken"] = $result["login"]["token"]; $token=$result["login"]["token"]; $postdata = "action=login&format=php&lgname=". $app["username"]. "&lgpassword=". $app["password"]. "&lgtoken=". $_SESSION["logintoken"]; $ch = curl_init; curl_setopt_array($ch, $app["curloptions"]); curl_setopt($ch, CURLOPT_URL, $app["apiURL"]); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); $result = unserialize(curl_exec($ch)); if(curl_errno($ch)){ $curl_error = "Error 004: ". curl_error($ch); }               curl_close($ch); //print_r($result);//die;//DEBUG } else { $other_error = "Error 006: Token error."; } } $url = 'http://138.85.252.123/mediawiki/api.php?action=move&from=Document_1&to=Document-1&token='; $url .= $_SESSION["logintoken"];

$curl = curl_init; curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($curl); curl_close($curl); echo $response;die; echo $url;

// Delete the cookie file unlink($app["cookiefile"]); // Destroy the session session_destroy; // End this file die($output); ?>