PHP code example of digfish / ivx-api2-php

1. Go to this page and download the library: Download digfish/ivx-api2-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

digfish / ivx-api2-php example snippets



use digfish\ivx_api2_php\InvoiceXpressRequest;

 class MyInvoiceXpressApi extends InvoiceXpressRequest
{
    public static function init($domain, $token)   {
        parent::init($domain, $token);
    }

    public function __construct($method) {
        self::init(IVX_DOMAIN,IVX_TOKEN);
        parent::__construct($method);
    }

    public function invoke($args = array(), $debug = false)    {
        $this->post($args);
        echo "** Invoking {$this->_method} **\n ";
        $response = $this->getResponse();
        $this->request();

        if (!$this->success()) {
            echo "Something got wrong!\n";
            echo "ERRORS:\n";
            var_dump($this->getError());
        }
        return $response;
    }
}

  define('IVX_DOMAIN','myFirm');
  define('IVX_TOKEN','--- the API key with 40 chars here ----');

  $api = new MyInvoiceXpressApi ( 'invoices.list' );
  $response = $api->invoke($args);

 $args['page'] = 3;
$response