skip to content

API - Add New Supplier

URL: NewSupplier.php

Required Fields:

username
password
supplier_name (255 characters max)
supplier_email (255 characters max)

Optional Fields:

supplier_account_number (255 characters max)
supplier_vat_nr (255 characters max)
supplier_phone_nr (20 characters max)
supplier_phone_nr2 (20 characters max)
supplier_fax_nr (20 characters max)
supplier_mobile_nr (20 characters max)
contact_name (255 characters max)
contact_surname (255 characters max)
supplier_postal_address1 (255 characters max)
supplier_postal_address2 (255 characters max)
supplier_postal_address3 (255 characters max)
supplier_postal_address4 (255 characters max)
supplier_physical_address1 (255 characters max)
supplier_physical_address2 (255 characters max)
supplier_physical_address3 (255 characters max)
supplier_physical_address4 (255 characters max)

Returns:

Integer; //only an integer will be returned, which is either the new supplier_id or an existing supplier_id if the Supplier already exists.

If anything else is returned, an error occurred and the error is returned as a string.

Example PHP code

$param['username'] = '';
$param['password'] = '';
$param['supplier_name'] = '';
$param['supplier_phone_nr'] = '';
$param['supplier_phone_nr2'] = '';
$param['supplier_mobile_nr'] = '';
$param['supplier_email'] = '';
$param['supplier_vat_nr'] = '';
$param['supplier_fax_nr'] = '';
$param['contact_name'] = '';
$param['contact_surname'] = '';
$param['supplier_postal_address1'] = '';
$param['supplier_postal_address2'] = '';
$param['supplier_postal_address3'] = '';
$param['supplier_postal_address4'] = '';
$param['supplier_physical_address1'] = '';
$param['supplier_physical_address2'] = '';
$param['supplier_physical_address3'] = '';
$param['supplier_physical_address4'] = '';
	
foreach ($param as $key => $val) {
  $request.= $key . '=' . urlencode($val);
  $request.= '&';
}
$request = substr($request, 0, -1); //remove trailing &

$url = 'https://www.invoicesonline.co.za/api/NewSupplier.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); //set the url
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //return as a variable
curl_setopt($ch, CURLOPT_POST, 1); //set POST method
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request); //set the POST variables
$response = curl_exec($ch); //run the whole process and return the response

 

Updated: Tue, 16 August 2016