Thanks to all who offered advice on logging in via API over multiple requests in the same
session. For posterity, here's what worked for a "post" function that
preserved the session information.
/**
* Perform an HTTP post to the MediaWiki API
* @param array $data - associative array of MW API parameters
* @return associative array
*/
function post($data) {
$jar = __DIR__ . '/cookies.txt';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->url);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_COOKIEJAR, $jar);
curl_setopt($ch, CURLOPT_COOKIEFILE, $jar);
$result = curl_exec($ch);
curl_close($ch);
return json_decode($result, true);
}
DanB