The following is a simple example of how to create a client record in HubSolv using PHP & cURL.
$_POST['firstname'] etc should be replaced with the appropriate fields you have captured from your form.
<?php
$username = 'your-username';
$password = 'your-password';
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$phone = $_POST['phone'];
$email = $_POST['email'];
/* creating a client record */
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, 'https://yoursubdomain.hubsolv.com/api/client/format/json');
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, array(
'HUBSOLV-API-KEY' => 'your-api-key',
'lead_source' => 'debt_form',
'lead_generator' => 'myleadgensite.com',
'lead_type' => 'website_lead',
'campaignid' => 1,
'firstname' => $firstname,
'lastname' => $lastname,
'phone_mobile' => $phone,
'phone_home' => $phone,
'email' => $email,
/* custom fields */
'number_of_debts' => '5',
'total_debt' => '£10000'
));
curl_setopt($curl_handle, CURLOPT_USERPWD, $username . ':' . $password);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
$result = json_decode($buffer);
if($result->status == "success_post") {
echo("Woo hoo! Successfull created client record no: " . $result->id);
}
else {
// deal with error
}
?>
Comments
0 comments
Please sign in to leave a comment.