Hi there,
I just started using the MediaWiki API today. I'm writting a script to insert about 500 new articles into the Wiki. I'm using PHP5, MedaWiki 1.13.3.
I've decided to use CURL to communicate with the APIs on my local machine. So far I can login, receive my lgtoken and request an edit token - which is all good. What I'm noticing however is when I use the examples on the site to send an action=edit I get this returned back:
Array ( [error] => Array ( [code] => help [info] => [*] =>
Plus the entire manual after it. What's even more strange is when I read the the manual more closely I don't see any references to action=edit being available. I have however found the same manual on other sites which list it accordingly. I'm completely baffled. Apparently 1.13.3 *does* have support for API editing.
I've attached a copy of the script I'm using as well just in case.
Thanks in advance,
Dave
On Wed, Jan 14, 2009 at 03:55:38PM -0500, David Di Biase wrote:
Plus the entire manual after it. What's even more strange is when I read the the manual more closely I don't see any references to action=edit being available. I have however found the same manual on other sites which list it accordingly. I'm completely baffled. Apparently 1.13.3 *does* have support for API editing.
Pardon me if this is a stupid question, but did you remember to set $wgEnableWriteAPI to true in your wiki's LocalSettings.php?
David Di Biase schreef:
Hi there,
I just started using the MediaWiki API today. I'm writting a script to insert about 500 new articles into the Wiki. I'm using PHP5, MedaWiki 1.13.3.
I've decided to use CURL to communicate with the APIs on my local machine. So far I can login, receive my lgtoken and request an edit token - which is all good. What I'm noticing however is when I use the examples on the site to send an action=edit I get this returned back:
Array ( [error] => Array ( [code] => help [info] => [*] =>
Plus the entire manual after it. What's even more strange is when I read the the manual more closely I don't see any references to action=edit being available. I have however found the same manual on other sites which list it accordingly. I'm completely baffled. Apparently 1.13.3 *does* have support for API editing.
The reason you don't see action=edit in the manual is probably because you've got editing disabled for anonymous users, or because the write API is disabled on your wiki. In the former case, verify you're properly logged in by checking meta=userinfo. In the latter case, set $wgEnableWriteAPI = true; in LocalSettings.php . In either case, you should be getting something like this:
Array ( [error] => Array ( [code] => unknown_action [info] => Unrecognized value for parameter 'action': edit ) )
A response with code=help and the help text included (even in a non-fm format) suggests you're using action=help or no action at all.
Roan Kattouw (Catrope)
Hi Brad, Roan,
Thanks for the quick reply. I, as a matter of fact, did not enable it. I just went ahead and researched the config settings I should have in LocalSettings.php and added these two:
$wgEnableWriteAPI = true; $wgEnableAPI = true;
Besides that I noticed that one of my links, as Roan suggested, was missing action=edit or rather it was there but I had a double ? ie. index.php?format=xml?action=. How silly of me.
I'm now getting this, which I'll work through in a bit as I might have an idea of what it is:
Array ( [error] => Array ( [code] => notext [info] => One of the text, appendtext and prependtext parameters must be set )
)
I did notice that the API enable option isn't described at all in the API reference manual. That's probably something people should know before trying to do editing and similar things. Unless I missed it (which tends to happen to me :-p).
Thanks and cheers,
Dave
On Wed, Jan 14, 2009 at 4:03 PM, Roan Kattouw roan.kattouw@home.nl wrote:
David Di Biase schreef:
Hi there,
I just started using the MediaWiki API today. I'm writting a script to insert about 500 new articles into the Wiki. I'm using PHP5, MedaWiki 1.13.3.
I've decided to use CURL to communicate with the APIs on my local
machine.
So far I can login, receive my lgtoken and request an edit token - which
is
all good. What I'm noticing however is when I use the examples on the
site
to send an action=edit I get this returned back:
Array ( [error] => Array ( [code] => help [info] => [*] =>
Plus the entire manual after it. What's even more strange is when I read
the
the manual more closely I don't see any references to action=edit being available. I have however found the same manual on other sites which list
it
accordingly. I'm completely baffled. Apparently 1.13.3 *does* have
support
for API editing.
The reason you don't see action=edit in the manual is probably because you've got editing disabled for anonymous users, or because the write API is disabled on your wiki. In the former case, verify you're properly logged in by checking meta=userinfo. In the latter case, set $wgEnableWriteAPI = true; in LocalSettings.php . In either case, you should be getting something like this:
Array ( [error] => Array ( [code] => unknown_action [info] => Unrecognized value for parameter 'action': edit ) )
A response with code=help and the help text included (even in a non-fm format) suggests you're using action=help or no action at all.
Roan Kattouw (Catrope)
Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
David Di Biase schreef:
Hi Brad, Roan,
Thanks for the quick reply. I, as a matter of fact, did not enable it. I just went ahead and researched the config settings I should have in LocalSettings.php and added these two:
$wgEnableWriteAPI = true; $wgEnableAPI = true;
Technically, the latter isn't necessary (because it's enabled by default and because the API is obviously working; you're not getting "the API is disabled" errors everywhere), but it doesn't hurt. The write API will also be enabled by default as of MediaWiki 1.14.
Besides that I noticed that one of my links, as Roan suggested, was missing action=edit or rather it was there but I had a double ? ie. index.php?format=xml?action=. How silly of me.
It's always the nasty little things.
I'm now getting this, which I'll work through in a bit as I might have an idea of what it is:
Array ( [error] => Array ( [code] => notext [info] => One of the text, appendtext and prependtext parameters must be set )
)
The text parameter (containing the text you want to put in your page) isn't set (or it got overridden by one of your ?foo=bar?baz=blah constructs again).
I did notice that the API enable option isn't described at all in the API reference manual. That's probably something people should know before trying to do editing and similar things. Unless I missed it (which tends to happen to me :-p).
You're right that it isn't mentioned in the api.php help, it should be. FWIW, it is mentioned in the API documentation at MW.org [1].
Roan Kattouw (Catrope)
mediawiki-api@lists.wikimedia.org