I had to help someone recently import leads from their website into their CRM Software (customer database app).
They have a RESTFul API so it was fairly straightforward.
I got the API key from the API settings inside the app and used the following PHP code:
$curl = curl_init();
$api_key = "xxxxxxxxxxxxxxxxxxxx;
$post_data = array(
"forename" => $customerForename,
"surname" => $customerSurname,
"email" => $customerEmail,
"phone" => $customerPhone,
"keys" => "f-4bc9a801-f63d-4b9c-b527-a0cbe902828b",
"values" => "Website Lead",
"keys" => "f-7515a3ca-b5ef-4f74-9c30-621f502886de",
"values" => $customerBudget );
CURLOPT_URL => "https://account.customerdatabase.app/api/customer/add",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => http_build_query($post_data),
CURLOPT_HTTPHEADER => array(
$response = curl_exec($curl);
Before calling the API I ran some validation checks on the data and put in place something to reduce form spam.
I also stored the data along with the result of the API call, this way if there was ever a problem calling the API the lead data would still exist and could be re-imported at a later time.
This code uses the cURL library to send a POST request to the specified URL with the specified POST fields. The $api_key variable contains the API key that will be sent in the request header. The response from the API is stored in the $response variable, which can then be parsed or used as needed.
There were other options to import more than just customer information on the software integration page but we didn’t need to make use of these.