Using the Sharpspring API to find the Lead ID of a Lead if you only have the the Lead email address available
function ns_ss_getLeads(){
/*Sharpspring API Keys*/
$accountID = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$secretKey = 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY';
$limit = 500;
$offset = 0;
$method = 'getLeads';
$params = array(
'where' => array('emailAddress' =>'a@gmail.com'));
$requestID = session_id();
$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),
'Expect: '
));
$result = curl_exec($ch);
curl_close($ch);
$obj = json_decode($result);
$leadid = $obj->result->lead[0]->id;
echo $leadid;
}