send_leads.php
4.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
class PostData
{
public function callback()
{
$channel = $_COOKIE['cstm_ppc_channel'];
$campaign = $_COOKIE['cstm_ppc_campaign'];
$placement = $_COOKIE['cstm_ppc_placement'];
$keyword = $_COOKIE['cstm_ppc_keyword'];
$device = $_COOKIE['cstm_ppc_device'];
$gclid = $_COOKIE['gclid'];
$fname = $_REQUEST['fname'];
$lname = $_REQUEST['lname'];
$email = $_REQUEST['email'];
$mobile = str_replace(' ', '', $_REQUEST['mobile']);
$source = $_REQUEST['source'];
$name = $fname . ' ' . $lname;
$crm_pro = "The Altitude";
$fullmobile = "91" . $mobile;
$cam= "Digital";
$sub_cam = "Organic Search";
$cam_cat = "Website";
$cam_ref = "Website - Realatte";
if($channel == "GoogleSearch")
{
$cam= "Digital";
$sub_cam = "Adwords";
$cam_cat = "Google Search";
$cam_ref = "Google Search - Realatte";
}
if($channel == "GoogleDiscovery")
{
$cam= "Digital";
$sub_cam = "Discovery";
$cam_cat = "Google Discovery";
$cam_ref = "Google Discovery - Realatte";
}
// Google Sheet Interation------------------
$postFields = "entry.449648499=" . $fname;
$postFields .= "&entry.1379833540=" . $email;
$postFields .= "&entry.758332158=" . $fullmobile;
$postFields .= "&entry.1693361781=" . $source;
$postFields .= '&entry.1830911442=' . urlencode($_COOKIE['cstm_ppc_campaign']);
$postFields .= '&entry.939490048=' . urlencode($_COOKIE['cstm_ppc_channel']);
$postFields .= '&entry.729166844=' . urlencode($_COOKIE['cstm_ppc_keyword']);
$postFields .= '&entry.839903606=' . urlencode($_COOKIE['cstm_ppc_placement']);
$postFields .= '&entry.2003337495=' . urlencode($_COOKIE['cstm_ppc_device']);
$postFields .= '&entry.1966964226=' . $gclid;
$ch3 = curl_init();
curl_setopt($ch3, CURLOPT_URL, "https://docs.google.com/forms/u/0/d/e/1FAIpQLSeSMHdszB8Zyn1lMN6FaQF-hkavyFV5FDMcgwsIWW2JT2yn2Q/formResponse");
curl_setopt($ch3, CURLOPT_POST, 1);
curl_setopt($ch3, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch3, CURLOPT_HEADER, 0);
curl_setopt($ch3, CURLOPT_RETURNTRANSFER, true);
$result3 = curl_exec($ch3);
/////////////////SFDC/////////////////////
$curl = curl_init();
$post_data = array(
'FirstName' => $fname,
'LastName' => $fname,
'Mobile' => $mobile,
'Email' => $email,
'ProjectName' => $crm_pro,
'Medium' => 'Marketing',
'Campaign' => $cam,
'SubCampaign' => $sub_cam,
'CampaignCategory' => $cam_cat,
'SourceURL' => "Digital",
'CampaignReference'=> $cam_ref,
'Origin'=> "API",
"Remarks"=>"Lead Remarks",
"WhatsappConsent"=> null
);
$json_post = json_encode($post_data);
// var_dump($json_post);
curl_setopt_array($curl, array(
//CURLOPT_URL => "https://assetz.secure.force.com/services/apexrest/Assetz_Lead?APIKey=41737365747a4150494c656164",
CURLOPT_URL => "https://assetzpropertymanagementservices.my.salesforce-sites.com/services/apexrest/Assetz_Lead?APIKey=41737365747a4150494c656164",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>$json_post,
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/json",
),
));
$response = curl_exec($curl);
var_dump($response,$cam);
$err = curl_error($curl);
curl_close($curl);
// die;
// do not delete
return true;
}
}