Greetings,
I'm having a weird problem using my under-construction Ruby API library
to talk to Wikimedia wikis. Login to eg. en.wikipedia.org seems to work
fine:
REQ: {"format"=>"xml", "lgpassword"=>"XXX", "action"=>"login",
"lgdomain"=>"local", "lgname"=>"Jpatokal"}
RES: <api><login result='NeedToken' cookieprefix='enwiki'
token='b07fdd1582a3faeed6244b58577a2b19'
sessionid='e310ae7389c8364e7ff4ac2e91258e54'/></api>
REQ: {"format"=>"xml", "lgpassword"=>"XXX", "action"=>"login",
"lgdomain"=>"local", "lgtoken"=>"b07fdd1582a3faeed6244b58577a2b19",
"lgname"=>"Jpatokal"}
RES: <api><login result='Success' lguserid='8155' cookieprefix='enwiki'
lgusername='Jpatokal' sessionid='e310ae7389c8364e7ff4ac2e91258e54'
lgtoken='3006f107e16173abcc8d9a2d46fbfea4'/></api>
I can request an edit token for a page and get back a seemingly suitable
one:
REQ: {"intoken"=>"edit", "format"=>"xml", "action"=>"query",
"titles"=>"User:Jpatokal/Sandbox", "prop"=>"info"}
RES: <api><query><pages><page starttimestamp='2010-08-11T10:26:00Z'
pageid='26692065' touched='2010-04-23T04:55:02Z' lastrevid='357765946'
title='User:Jpatokal/Sandbox'
edittoken='6069665f65933586ddfa540d38d30d6a+\' ns='2' counter='0'
length='67'/></pages></query></api>
However, when I send it back, it's rejected with "badtoken".
REQ: {"format"=>"xml", "title"=>"User:Jpatokal/Sandbox",
"token"=>"6069665f65933586ddfa540d38d30d6a+\\", "text"=>"haxx0r",
"action"=>"edit", "summary"=>""}
RES: <api><error code='badtoken' info='Invalid token'/></api>
What's wrong? The same sequence works fine on my local test wiki.
Here's a packet trace of the actual edit request, which looks fine to
me, including the URL-encoding of the token:
POST /w/api.php HTTP/1.1
Accept: */*; q=0.5, application/xml
User-Agent: MediaWiki::Gateway/0.0.1
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Cookie:
centralauth_Session=f5b0c979d3097489deca4b759f9d49af;centralauth_Token=8f57e36225df5a8f71cfd623718dff59;centralauth_User=Jpatokal;domain=.wikipedia.org;enwikiUserID=8155;enwikiUserName=Jpatokal
Content-Length: 120
Host: en.wikipedia.org
format=xml&title=User%3AJpatokal%2FSandbox&token=6069665f65933586ddfa540d38d30d6a%2B%5C&text=haxx0r&action=edit&summary=
Cheers,
-jani
Hi,
This started happening a few minutes ago:
(mwapi putedit error: u'<?xml version="1.0"?><api><error
code="internal_api_error_DBConnectionError" info="Exception Caught: DB
connection error: Unknown error (10.0.6.26)"
xml:space="preserve">\n\n#0
/usr/local/apache/common-local/wmf-deployment/includes/db/LoadBalancer.php(685):
DatabaseBase->reportConnectionError(\'Unkn', page u'[[fi:aero]]')
eh?
best, Robert
Hi,
Is there a way to walk the category tree down or up using http://en.wikipedia.org/w/api.php? I couldn't figure it out.
-Pierre
________________________________
Pierre-Olivier Latour
pol(a)cooliris.com