-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplateMessages.php
More file actions
42 lines (37 loc) · 1.19 KB
/
templateMessages.php
File metadata and controls
42 lines (37 loc) · 1.19 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
<?php
/*
- $_POST['Worker']
- $_POST['CustomerId']
- $_POST['Location']
- $_POST['ConversationSid']
*/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://xxx.api-us1.com/api/3/contacts/' . $_POST['CustomerId'],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Api-Token: xxxx',
'Cookie: PHPSESSID=xxx; em_acp_globalauth_cookie=xxxx'
),
));
$response = curl_exec($curl);
$res = json_decode($response, true);
//dd($res['contact']['phone']);
$contact = $res['contact'];
echo '[
{
"display_name": "General",
"templates": [
{ "content": "Great! Let me know if you have any questions. 😀" },
{ "content": "The easiest way to get an estimate is at www.example.com" },
{ "content": "Hi ' . $contact['firstName'] . '. 👋🏻 This is agent one. Do you have any questions about your service estimate?" },
{ "content": "Let\'s schedule a 15 minute phone interview https://calendly.com/xxxxx/15-minute-phone-interview 😀" },
]
}
]';