forked from brendanblackwood/twilio-calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddEvent.php
31 lines (27 loc) · 832 Bytes
/
addEvent.php
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
<?php
require 'common.php';
$fp = fopen('debug.log', 'a');
$log = print_r($_REQUEST, true) . "\n";
if ($_REQUEST['TranscriptionStatus'] == 'completed') {
$sText = $_REQUEST['TranscriptionStatus'];
$sFromNumber = $_REQUEST['From'];
} else if ($_REQUEST['Body']) {
$sText = $_REQUEST['Body'];
$sFromNumber = $_REQUEST['From'];
} else {
// @todo add some failure logic
}
try {
if ($aAccount = getAccount($sFromNumber)) {
$oGoogleClient = getGoogleClient($aAccount['email'], $aAccount['pass']);
createQuickAddEvent($oGoogleClient, $sText);
} else {
// this person doesn't exist in the system, we should probably message that to them in some way
}
} catch (Exception $e) {
// @todo add some failure logic
$log .= $e->getMessage() . "\n";
}
fwrite($fp, $log, strlen($log));
fclose($fp);
?>