You should probably fake your own user agent? Something like commonsapi/1.0
I'm only faking it because with the default agent (whatever it is for PHP), requests often don't work on Mediawiki sites. Not sure what would happen if I make my own...
It will work. Actually, it's semi-officially requested/recommended that you use your own descriptive user agent string, including some means to learn more about the tool and/or contact you -- or selectively block it if things go wrong. And it does work, I use it for my own stuff.
General request to ALL bot and script makers, for any purpose: Please DO NOT FAKE UA STRINGS! Please set your own, descriptive ones! This is a question of good netizenship (as in "follow the spec" and "be cooperative").
Thank you -- Daniel