Skip to content

Instantly share code, notes, and snippets.

@rondorkerin
Last active January 10, 2018 20:17
Show Gist options
  • Save rondorkerin/bd1b6fc93752b9b069e0 to your computer and use it in GitHub Desktop.
Save rondorkerin/bd1b6fc93752b9b069e0 to your computer and use it in GitHub Desktop.
An Example PHP Request With SharpSpring APIv1
<?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 = '<account-id>';
$secretKey = '<secret-key>';
$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;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment