Ad Widget

Collapse

Access API from URL (html, php...)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bricka
    Junior Member
    • Jun 2018
    • 23

    #1

    Access API from URL (html, php...)

    Hello

    My zabbix is http://x.x.x.x/zabbix. I want to make page (in html, php or so on) http://x.x.x.x/zabbix/test that access api.

    From command line api work's (python): Connected to Zabbix API Version 4.2.5

    But I cant find any tutorial how to make web page to access api..



    Thank's
  • Melody582
    Junior Member
    • Sep 2019
    • 1

    #2
    There is no web page.

    showbox
    Last edited by Melody582; 20-09-2019, 07:49.

    Comment

    • 1berto
      Senior Member
      • Sep 2018
      • 182

      #3
      What do you mean by 'Access the API' ?
      If you have a zabbix server running in http://x.x.x.x/zabbix, the api address is http://x.x.x.x/zabbix/api_jsonrpc.php, if you want to make a page where you give 'commands' using the API you will need to create the page (using python or any other language) that build the json requests and translate the responses for the user.

      Comment

      • bricka
        Junior Member
        • Jun 2018
        • 23

        #4
        Thank's 1berto.

        It work's.

        <?php

        require 'inc/ZabbixApi.class.php';

        try {

        $api = new ZabbixApi\ZabbixApi();

        $api->setApiUrl('http://x.x.x.x/zabbix/api_jsonrpc.php');

        $api->userLogin(array('user' => 'x', 'password' => 'x'));
        var_dump($api);
        // if Connected you can see the 'authToken'
        } catch(Exception $e) {

        // Exception in ZabbixApi catched
        echo $e->getMessage();

        }

        A PHP library for the Zabbix™ JSON-RPC API. Contribute to confirm/PhpZabbixApi development by creating an account on GitHub.

        Comment

        Working...