Hi, I went through the sample steps in the API examplehttp://www.mediawiki.org/wiki/API:Edit_-_Create%2526Edit_pages#Example on using the api to edit a page:
1. login your bot: ( I just used my admin login) - it succeeds 2. get a token - it suceeds 3. post to api.php - this is the form I usehttp://pathboston.com/forms/mw/append21.html- after I get the token I replace the +\ with %2B%5C Alas, I get this error:
<?xml version="1.0"?> <api> <error code="badtoken" info="Invalid token" xml:space="preserve">
my form code is:
<form id="form1" name="Update" method="post" action="../../hum310/api.php?action=edit"> <label>title: <input type="text" name="title" id="textfield" value="Talk:Main_Page" /></label><br /> <label>section: <input type="text" name="section" id="textfield" value="new"/></label><br /> <label>summary: <input type="text" name="summary" id="textfield" value="Hello%20Worldwide"/></label><br /> <label>text: <input type="text" name="text" id="textfield" value="Hello%20everyone!"/></label><br /> <label>watch: <input type="text" name="watch" id="textfield" /></label><br /> <label>basetimestamp: <input type="text" name="basetimestamp" id="textfield" value="2008-03-20T17:26:39Z"/></label><br /> <label>token: <input type="text" name="token" id="textfield" value="96a50d37e6c48e6d0def3dd64dc9450d%2B%5C" size=50/></label><br /> <input name="" type="submit" value="send" /> </form> <a href="http://pathboston.com/hum310/api.php?action=query&prop=info|revisions&intoken=edit&titles=Main%20Page">get token</a>
Thanks,
Timothy S. McKenna Humanities teacher Parkway Academy of Technology and Health, a Boston Public High School 1205 VFW Parkway, Boston, MA 02132 rm404 tim@sitebuilt.net, http://sitebuilt.net exp. course news on twitter, id: mrtmckenna class wiki sites: http://pathboston.com/hum Humanities 3 http://pathboston.com/poets class159 (857)498-2574 (mobile), (617)524-0938 (home)
Tim McKenna wrote:
Hi, I went through the sample steps in the API examplehttp://www.mediawiki.org/wiki/API:Edit_-_Create%2526Edit_pages#Example on using the api to edit a page:
- login your bot: ( I just used my admin login) - it succeeds
- get a token - it suceeds
- post to api.php - this is the form I
usehttp://pathboston.com/forms/mw/append21.html- after I get the token I replace the +\ with %2B%5C
Wrong. All form items must be urlescaped. That process will convert +\ to %2B%5C, spaces to %20, etc. Process each value, do not perform blind string replaces.
Since you are using a web form, when submitting *your browser already urlescapes it*. So you must place the original text. Thus, you are sending the token ababab%2B%5C (sent as ababab%252B%255C) instead of ababab+\
mediawiki-l@lists.wikimedia.org