EzzyBills User Guide

Using EzzyBills API – PHP or cURL examples

PHP example

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.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44<?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 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