· 4 years ago · Feb 05, 2021, 02:22 PM
1function sendToCRM($data){
2 $utm_source = (isset($data['utm_source']) ? $data['utm_source'] : 'Odigma Lead');
3 $input = array([
4 'Attribute' => 'FirstName',
5 'Value' => $data['name'],
6 ],
7 [
8 'Attribute' => 'LastName',
9 'Value' => '',
10 ],
11 [
12 'Attribute' => 'EmailAddress',
13 'Value' => $data['email'],
14 ],
15 [
16 'Attribute' => 'Phone',
17 'Value' => $data['phone'],
18 ],
19 [
20 'Attribute' => 'Notes',
21 'Value' => $data['message'],
22 ],
23 [
24 'Attribute' => 'Source',
25 'Value' => $utm_source,
26 ]
27 );
28
29
30 $curl = curl_init();
31 $json = json_encode($input, 128);
32
33 $credentials = array(
34 'accessKey' => '',
35 'secretKey' => ''
36 );
37
38 $url = 'https://api-in21.leadsquared.com/v2/LeadManagement.svc/Lead.Capture?'.http_build_query($credentials);
39
40
41 $ch = curl_init( $url );
42 curl_setopt( $ch, CURLOPT_POST, true);
43 curl_setopt( $ch, CURLOPT_POSTFIELDS, $json);
44 curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
45 curl_setopt( $ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "cache-control: no-cache"));
46 curl_setopt( $ch, CURLOPT_HEADER, 0);
47 // curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query($_data));
48 curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
49
50 $response = curl_exec( $ch );
51
52 return $response;
53 }