Anybody know what I am doing wrong here? API Login doesn't seem to
work if I specify format=xml, but does work with the default (html)
format. I *am* using the POST method. The username and password
contain no odd characters so it almost certainly isn't a urlencoding
problem.
I have also tried this with Wikimedia Commons login with the same result.
The following is a shell session using the lynx browser to illustrate
the problem. Sensitive data has been blanked out. The second browser
invocation is identical to the first except for "&format=xml", but
instead of returning xml it returns only blank lines.
tony@home:~$ lynx -post-data
http://en-wikipedia.org/w/api.php
action=login&lgname=USERNAME&lgpassword=PASSWORD
---
You are looking at the HTML representation of the XML format.
HTML is good for debugging, but probably is not suitable for your
application.
See [1]complete documentation, or [2]API help for more information.
<?xml version="1.0"?>
<api>
<login result="Success" lguserid="XXX"
lgusername="USERNAME"
lgtoken="TOKEN" cookieprefix="enwiki" sessionid="SESSIONID"
/>
</api>
References
1.
http://www.mediawiki.org/wiki/API
2.
http://en.wikipedia.org/w/api.php
tony@home:~$ lynx -post-data
http://en-wikipedia.org/w/api.php
action=login&lgname=USERNAME&lgpassword=PASSWORD&format=xml
---
tony@home:~$