User:Bcoughlan/Login with curl

Note : this is not updated and don't work ... you will got a beautifull "Fetching a token via action=login is deprecated. Use action=query&meta=tokens&type=login instead." error...

Log in through the MW API. Tested on MW 1.16

Updated for MW: 1.26.0

Different versions of mediawiki seems to be able to have the api.php in different locations - changed location for MW 1.26.0

Dont close the connection to the server ($ch) before you run the request against it the second time or curl, will initiate a new connection and give you a new session (token) - moved $ch out of func and globalled it.