A common method of connecting to APIs is using the low level cURL utility. This article will provide example code for Lead Gen & CRM's Open API.
| Administrators | ✓ | |
| Company Managers | ||
| Marketing Managers | ||
| Sales Managers | ||
| Salespersons | ||
| Jr. Salespersons |
This article provides an example of how to structure code for Lead Gen & CRM's API. However, given the size and scope of the API, information is broken up and is contained in different articles. Each article focuses on a specific function of Lead Gen & CRM's API. Additional API information can be found in the following articles:
<?php
/** Get all leads with a limit of 500 results */
$limit = 500;
$offset = 0;
$method = 'getLeads';
$params = array('where' => array(), 'limit' => $limit, 'offset' => $offset);
$requestID = session_id();
$accountID = '';
$secretKey = '';
$data = array(
'method' => $method,
'params' => $params,
'id' => $requestID,
);
$queryString = http_build_query(array('accountID' => $accountID, 'secretKey' => $secretKey));
$url = "http://api.sharpspring.com/pubapi/v1/?$queryString";
$data = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data)
));
$result = curl_exec($ch);
curl_close($ch);
echo $result;
?>
The following code is an example of how to use the where clause:
{
"method": "getLeads",
"params": {
"where": {
"id": [1, 2, 3, 4]
}
},
"id": 123
}
The following code is an example of how to use the createLeads method to create a lead in Lead Gen & CRM:
{
"method":"createLeads",
"params":
{"objects":
[
{"firstName":"john","lastName":"smith","emailAddress":"john@smith.com"},
{"firstName":"jane","lastName":"doe","emailAddress":"jane@doe.com"}
]
},
"id":"<your request ID>"
}
The following code is an example of how to use the updateLeads method to update leads already in Lead Gen & CRM:
{
"method":"updateLeads",
"params":
{"objects":
[
{"id":"<lead ID>","firstName":"fooUpdate","lastName":"barUpdate"}
]
},
"id":"<your request ID>"
}
The following code is an example of how to use the deleteLeads method to delete leads in Lead Gen & CRM:
{
"method":"deleteLeads",
"params":
{"objects":
[
{"id":"<lead ID>"},
{"id":"<another lead ID>"},
]
},
"id":"<your request ID>"
}
Copyright © 2026 · All Rights Reserved · Constant Contact · Privacy Center