1. Home
  2. Docs
  3. Adding A Customer Transaction
  4. Example Code

Example Code

The following example is in PHP, and when the correct Authentication headers have been added, results in a successful API test.

During both testing and development we have found Postman to be an invaluable application, with the added bonus of supplying code in many languages including C#, Python, Ruby, Java, Javascript, and many more!

You can grab the Postman application from their website: Download Postman

Example code in PHP:

<?php

// Get AppID, Username, & Password from your account manager.

$url = "https://app.instantfeedback.com.au/api/customer/new/test/";

$headers = [
"Content-Type: application/json",
"App-ID: 12345678-WXYZ-1234-DEFG-XXXXXXXXXXXX",
"App-Username: 12345678-WXYZ-1234-DEFG-XXXXXXXXXXXX",
"App-Password: 12345678-WXYZ-1234-DEFG-XXXXXXXXXXXX"
];

$data = (object)[
"customerFirstName" => "John Smith",
"customerMobileNumber" => "+61400123456",
"customerEmailAddress" => "johnsmith@example.com",
"customerStreamId" => "12345678-WXYZ-1234-DEFG-XXXXXXXXXXXX",
"customerUniqueInfo" => "1234567890" // Transaction ID from your CRM
];

$data = json_encode($data);

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $data,
CURLOPT_HTTPHEADER => $headers
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}

?>
Was this article helpful to you? Yes No

How can we help?