Skip to content

Zabbix Token with SSL options #11

Description

@roberthau1981
<?php
require_once("../src/ZabbixApi.php");

use IntelliTrend\Zabbix\ZabbixApi;
use IntelliTrend\Zabbix\ZabbixApiException;

print "Zabbix API Example\n";
print " Connect to API, ignore certificate/hostname and get number of hosts\n";
print "=====================================================\n";

$zabUrl ='https://blah/zabbix';
$zabToken = '123456';

$zbx = new ZabbixApi();
try {
        // disable verification of certificate and hostname
        $options = array('sslVerifyPeer' => false, 'sslVerifyHost' => false);
        $zbx->login($zabUrl, $zabToken,$options); <---- This looks like it only wants a password because of the $options.
        $result = $zbx->getApiVersion();
        print "Remote Zabbix API Version:$result\n";
        // Get number of host available to this useraccount
        $result = $zbx->call('host.get',array("countOutput" => true));
        print "Number of Hosts:$result\n";
} catch (ZabbixApiException $e) {
        print "==== Zabbix API Exception ===\n";
        print 'Errorcode: '.$e->getCode()."\n";
        print 'ErrorMessage: '.$e->getMessage()."\n";
        exit;
} catch (Exception $e) {
        print "==== Exception ===\n";
        print 'Errorcode: '.$e->getCode()."\n";
        print 'ErrorMessage: '.$e->getMessage()."\n";
        exit;
}



Zabbix API Example
 Connect to API, ignore certificate/hostname and get number of hosts
=====================================================
Remote Zabbix API Version:6.0.22
==== Zabbix API Exception ===
Errorcode: -32602
ErrorMessage: Invalid params. [Invalid parameter "/password": a character string is expected.]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions