Hi,
I am getting an issue using the edit action of the MediaWiki API. Whenever I send an edit request I am getting an error response stating badtoken. The question I have is which token is this referring to. Is this referring to my cookie token which I have instructed curl to store or is it referring to the edit token.
The login operation is given the following parameters using a POST request;
action=login&lgname=<bot username>&lgpassword=<bot password>&format=php
To obtain the token I am using the following parameters in a GET request ;
action=query&intoken=edit&titles=IBWikiBotTest&prop=info|revisions&format=ph p.
The following parameters are then used as part of a POST request in the attempt to create a new page;
action=edit&title=IBWikiBotTest&summary=Page created by the IBWikiBot.&text=This is some test content added by the IBWikiBot.&md5=e21e79d8ee8ee6b5038c9bac090decf1&bot&recreate&token=0e72e1361 3a9408646cae5aa1a630d0a+\&format=php
The unserialized response from the API is:
Array
(
[error] => Array
(
[code] => badtoken
[info] => Invalid token
)
)
Any insight on this would be greatly appreciated.
Marcus Ramsden
---
Marcus Ramsden
Technical Project Assistant
Learning Societies Laboratory, Electronics and Computer Science
University of Southampton
3069, Building 32, Highfield Campus
Southampton SO17 1BJ
www.southampton.ac.uk/ecs
Marcus Ramsden schreef:
Hi,
I am getting an issue using the edit action of the MediaWiki API. Whenever I send an edit request I am getting an error response stating badtoken. The question I have is which token is this referring to. Is this referring to my cookie token which I have instructed curl to store or is it referring to the edit token.
The badtoken error always refers to the edit token.
The login operation is given the following parameters using a POST request;
action=login&lgname=<bot username>&lgpassword=<bot password>&format=php
To obtain the token I am using the following parameters in a GET request ;
action=query&intoken=edit&titles=IBWikiBotTest&prop=info|revisions&format=php.
The following parameters are then used as part of a POST request in the attempt to create a new page;
action=edit&title=IBWikiBotTest&summary=Page created by the IBWikiBot.&text=This is some test content added by the IBWikiBot.&md5=e21e79d8ee8ee6b5038c9bac090decf1&bot&recreate&token=0e72e13613a9408646cae5aa1a630d0a+\&format=php
Try removing the second backslash (you don't need to escape backslashes in URLs) and encoding the + as %2B (if you don't do that, it could end up being converted to a space).
Roan Kattouw (Catrope)
On Tue, Sep 30, 2008 at 2:34 PM, Roan Kattouw roan.kattouw@home.nl wrote:
The following parameters are then used as part of a POST request in the attempt to create a new page;
action=edit&title=IBWikiBotTest&summary=Page created by the IBWikiBot.&text=This is some test content added by the IBWikiBot.&md5=e21e79d8ee8ee6b5038c9bac090decf1&bot&recreate&token=0e72e13613a9408646cae5aa1a630d0a+\&format=php
Try removing the second backslash (you don't need to escape backslashes in URLs) and encoding the + as %2B (if you don't do that, it could end up being converted to a space).
Roan Kattouw (Catrope)
Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
You should actually encode the +\ in proper url encoding. Those characters exist on purpose in edittokens to detect software that handles escaping badly.
Bryan
mediawiki-api@lists.wikimedia.org