Hello, I will use the mediawiki API to edit page in my wiki. First, with POST requets, I make : api.php?action=login&lgname=***&lgpassword=***&format=xml I take the cookies and send, also in POST, : api.php?action=query&prop=info|revisions&intoken=edit&titles=Utilisateur:JonathanMM/Test_Trillian&format=xml I have a token. I take this token and use the urlencode function in this token. Then, I make : http://www.nocle.fr/nolife-wiki/api.php?action=edit&title=Utilisateur:Jo... But, I have this error :
<?xml version="1.0"?> <api> <error code="badtoken" info="Invalid token" xml:space="preserve"> </error> </api>
Where is the problem ? Thank's for your help, and sorry for my English, but I'm french ;) JonathanMM
2009/12/23 JonathanMM jonathanmm@free.fr:
Hello, I will use the mediawiki API to edit page in my wiki. First, with POST requets, I make : api.php?action=login&lgname=***&lgpassword=***&format=xml I take the cookies and send, also in POST, : api.php?action=query&prop=info|revisions&intoken=edit&titles=Utilisateur:JonathanMM/Test_Trillian&format=xml I have a token. I take this token and use the urlencode function in this token. Then, I make : http://www.nocle.fr/nolife-wiki/api.php?action=edit&title=Utilisateur:Jo...
Could you echo or var_dump() the value of $token and tell us?
Roan Kattouw (Catrope)
Le 23/12/2009 20:27, Roan Kattouw a écrit :
2009/12/23 JonathanMMjonathanmm@free.fr:
Hello, I will use the mediawiki API to edit page in my wiki. First, with POST requets, I make : api.php?action=login&lgname=***&lgpassword=***&format=xml I take the cookies and send, also in POST, : api.php?action=query&prop=info|revisions&intoken=edit&titles=Utilisateur:JonathanMM/Test_Trillian&format=xml I have a token. I take this token and use the urlencode function in this token. Then, I make : http://www.nocle.fr/nolife-wiki/api.php?action=edit&title=Utilisateur:Jo...
Could you echo or var_dump() the value of $token and tell us?
Roan Kattouw (Catrope)
No problem : var_dump($token); string(38) "cf34d859be3d7ee167bab0c2afafdfda%2B%5C"
2009/12/23 JonathanMM jonathanmm@free.fr:
No problem : var_dump($token); string(38) "cf34d859be3d7ee167bab0c2afafdfda%2B%5C"
The token looks OK. What I think the problem is is that you're not passing the login cookies back.
When you log in, the API sends you a couple of cookies. You need to store these cookies and send them back in every subsequent request. Whichever library you're using to do your HTTP requests probably has an interface for this.
To test if this assessment is correct, hardcode $token to "%2B%5C" and see if that either produces a working edit by an anonymous user or a permissions error.
Roan Kattouw (Catrope)
Le 23/12/2009 20:40, Roan Kattouw a écrit :
2009/12/23 JonathanMMjonathanmm@free.fr:
No problem : var_dump($token); string(38) "cf34d859be3d7ee167bab0c2afafdfda%2B%5C"
The token looks OK. What I think the problem is is that you're not passing the login cookies back.
When you log in, the API sends you a couple of cookies. You need to store these cookies and send them back in every subsequent request. Whichever library you're using to do your HTTP requests probably has an interface for this.
I'm send the cookie of the log in at every API request.
To test if this assessment is correct, hardcode $token to "%2B%5C" and see if that either produces a working edit by an anonymous user or a permissions error.
I've the even error : badtoken :/ (My only request : http://www.nocle.fr/nolife-wiki/api.php?action=edit&title=Utilisateur:Jo...) JonathanMM
mediawiki-api@lists.wikimedia.org