Search code examples
phpzabbix

Zabbix login with php


I have written a simple test page which logins to Zabbix server using the API Provided in https://github.com/confirm-it-solutions/PhpZabbixApi/releases

Below is the code i have written.

    <?php
// load ZabbixApi
require_once 'build/ZabbixApi.class.php';
use ZabbixApi\ZabbixApi;

try
{
    // connect to Zabbix API
    $api = new ZabbixApi('http://xxx.xxx.xxx/zabbix/', 'credit', 'debit','','');

    /* ... do your stuff here ... */
}
catch(Exception $e)
{
    echo"In Exception <br/>";
    // Exception in ZabbixApi catched
    echo $e->getMessage();
}
?>

and below is the error i am getting. "In Exception Could not decode JSON response"

Thanks in advance.


Solution

  • You are missing /api_jsonrpc.php in your URL.