REST API
Authorization in REST
If requests are made from localhost, then authorization is not required.
curl 'http://172.16.156.223/admin-cabinet/session/start' \
-X 'POST' --cookie-jar auth-cookies.txt \
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
-H 'X-Requested-With: XMLHttpRequest' \
--data 'login=admin&password=adminpassword'$host = '172.16.156.223';
$login = 'admin';
$password = 'admin';
$jar = new \GuzzleHttp\Cookie\CookieJar;
$client = new \GuzzleHttp\Client(['cookies' => $jar]);
$options = [
'headers' => [
"Content-Type" => "application/x-www-form-urlencoded; charset=UTF-8",
"X-Requested-With" => "XMLHttpRequest"
],
'body' => http_build_query(['login' => $login,'password' => $password])
];
$resultHttp = $client->request('POST', "http://$host/admin-cabinet/session/start", $options);
$code = $resultHttp->getStatusCode();
if($code === 200) {
$content = $resultHttp->getBody()->getContents();
$authId = $jar->getCookieByName('PHPSESSID');
print_r($authId->getValue());
}Use $authId for other API requests.
JSON response:
{
"success": true,
"reload": "index/index",
"message": []
}In this example:
"172.16.156.223" - MikoPBX address
"admin" - Web interface user name
"adminpassword" - Web interface password
"auth-cookies.txt" - file for storing authorization data
Get peer statuses
JSON Response:
Get peer status
JSON Response:
Get provider statuses
JSON Response:
Last updated
Was this helpful?