Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zabbix Token with SSL options #11

Open
roberthau1981 opened this issue Nov 1, 2023 · 1 comment
Open

Zabbix Token with SSL options #11

roberthau1981 opened this issue Nov 1, 2023 · 1 comment

Comments

@roberthau1981
Copy link

roberthau1981 commented Nov 1, 2023

<?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.]

@roberthau1981 roberthau1981 changed the title Zabbix Token with SSL Zabbix Token with SSL options Nov 1, 2023
@DodoMoep
Copy link

Have you tried it with the "loginToken" Method instead of "login"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants