Hello,
the procedure that I follow is this:
- require login token with this http request:
http://localhost/mediawiki-1.28.2/api.php?action=query&meta=tokens&type=login
- start a http Post request with a test page written in php:
<?php
$url = 'http://localhost/mediawiki-1.28.2/api.php?action=login';
$data = array('lgname' => 'Ulisse', 'lgpassword' => 'itaca', 'lgtoken' => "4ae0db11ef80a42e29411c39f8c8a3f8595a09e8+\\");
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) { /* Handle error */ }
var_dump($result);
The result is:
{
"warnings": {
"login": {
"*": "Fetching a token via action=login is deprecated. Use action=query&meta=tokens&type=login instead."
}
},
"login": {
"result": "NeedToken",
"token": "edc7dace7148aeeed21dbeb0a54b0d43595a0a1f+\\"
}
}
Anyone help me?