EzzyBills User Guide

Using EzzyBills API – PHP or cURL examples

PHP example

<?php

// Login: replace empty strings with your info and supplied api key
$USER = "";
$PASS = "";
$APIKey = "";

// Invoice id
$INVOICE_ID = "";

$params = array('user' => $USER, 'pwd' => $PASS, 'APIKey' => $APIKey);

$u = "https://app.ezzydoc.com/EzzyService.svc/Rest";
$url = $u."/Login?".http_build_query($params);

$ch = curl_init();
$cookie_file_path = "cookies.txt";

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path); 
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path); 

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}

echo $result.PHP_EOL;

$invParams = array('APIKey' => $APIKey, 'invoiceid' => $INVOICE_ID);
$url = $u."/getInvoiceHeaderBlocks?".http_build_query($invParams);

curl_setopt($ch, CURLOPT_URL, $url);

$result = curl_exec($ch);

echo $result;

curl_close($ch);

?>

The below example logs into EzzyBills with a given username and password and gets the invoice headers for a given invoice. Note: this api example requires the cURL extension for PHP to be enabled.

The php settings used for this example can be downloaded here.

cURL example

The below example is a shell script that authenticates with EzzyBills then calls getInvoiceDetails for a given invoiceid. To use this example, save this code as a shell script (.sh) and replace the APIKEY, USERNAME, PASSWORD and INVOICE_ID with the appropriate values.

curl -c cookies.txt “https://app.ezzydoc.com/EzzyService.svc/Rest/Login?APIKey=[INSERT API KEY]&user=[INSERT USERNAME]&pwd=[INSERT PASSWORD]”
echo “\n”
curl -b cookies.txt “https://app.ezzydoc.com/EzzyService.svc/Rest/getInvoiceDetails?APIKey=[INSERT API KEY]&invoiceid=[INSERT INVOICE_ID]”

Note: -c is to save authentication cookie from login request to “cookies.txt”

          -b is to load authentication cookie from file “cookies.txt”

you can run this shell script with:

 chmod +x curltest.sh            (this is to allow the shell script to be executed)

 ./curltest.sh                            (run the shell script)

Sections of Article