API - PHP Example

$curl_handle=curl_init();

$post_data='apiKey=ABCDEFG';

$post_data.='&name='.urlencode($_POST['name']);

$post_data.='&email='.urlencode($_POST['email']);

$post_data.='&cellphone='.urlencode($_POST['phone']);

$post_data.='&customertype='.urlencode($_POST['type']);

curl_setopt($curl_handle,CURLOPT_URL,'https://rental.software/api6/customers/');

curl_setopt($curl_handle, CURLOPT_TIMEOUT,5);

curl_setopt($curl_handle, CURLOPT_POST,1);

curl_setopt($curl_handle, CURLOPT_POSTFIELDS,$post_data);

curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);

$output_json = curl_exec($curl_handle);

$httpCode = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE);

if($httpCode<>201 && $httpCode<>409){

//error

}

$output = json_decode($output_json);

$customer_id = $output->recordid;

Is this article helpful?
0 0 0