PHP API Example

PHP API Example

$api_key = '892f86d5-da86-4e98-9343-1976a375';
$post_url = "https://portal.xenis.com.au/api/$api_key/customer/add";
 
$post_data = array(
    'name' => 'Test',
    'surname' => 'Person',
    'phone' => '0411222333',
);
$data_string = json_encode($post_data);
 
$ch = curl_init($post_url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // don't worry about ssl too much 
curl_setopt($ch, CURLOPT_SSLVERSION,1);  
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data_string))
);
 
$result = curl_exec($ch);
header('Location: success.html');