Hi,
I'm trying to edit a page and upload an image using Mediawiki API call.
I've logged in as user. I've fetched the edit token using below code: $editToken = urlencode($wgUser->editToken($salt=,$request = $wgRequest));
Below is the post data I'm passing to upload an image using Mediawiki Api, $imgUploadData = "filename=Wiki.png&token=%2B%5C&url=http%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fen%2Fb%2Fbc%2FWiki.png";
Below is the curl call to execute the api,
$submitUrl = "http://example.com/api.php?action=upload&format=json"; $curlObj = curl_init(); curl_setopt($curlObj, CURLOPT_URL, $submitUrl); curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curlObj, CURLOPT_POST, 1); curl_setopt($curlObj, CURLOPT_POSTFIELDS, $imgUploadData); $objData = curl_exec($curlObj); curl_close($curlObj); return $objData;
When executing the API call its giving the error as below,
<api> <error code="badtoken" info="Invalid token" xml:space="preserve"> </error> </api>
I'm getting the error as "badtoken" token even after sending the proper edit token. Can you please help me out to sort this issue. I'm struck with this for the past 1
week.