· 5 years ago · Jun 29, 2020, 01:18 AM
1<?php
2
3 /** Get all leads with a limit of 500 results */
4
5 $limit = 500;
6 $offset = 0;
7
8 $method = 'getLeads';
9 $params = array('where' => array(), 'limit' => $limit, 'offset' => $offset);
10 $requestID = session_id();
11 $accountID = '';
12 $secretKey = '';
13
14 $data = array(
15 'method' => $method,
16 'params' => $params,
17 'id' => $requestID,
18 );
19
20 $queryString = http_build_query(array('accountID' => $accountID, 'secretKey' => $secretKey));
21 $url = "http://api.sharpspring.com/pubapi/v1/?$queryString";
22
23 $data = json_encode($data);
24 $ch = curl_init($url);
25 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
26 curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
27 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
28 curl_setopt($ch, CURLOPT_HTTPHEADER, array(
29 'Content-Type: application/json',
30 'Content-Length: ' . strlen($data)
31 ));
32
33 $result = curl_exec($ch);
34 curl_close($ch);
35
36 echo $result;
37
38?>