-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwilioBridge.php
59 lines (44 loc) · 1.62 KB
/
twilioBridge.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
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
<?php
$coreID = '53ff67066667574854462467';
//$parsedMsg = preg_split("/[\s,]+/",$_REQUEST['Body']);
$message = $_REQUEST['Body'];
// if the sender is known, then greet them by name
// otherwise, consider them just another monkey
/*$pos = strpos($parsedMsg[0], '@');
if($pos !== false) { //first term was the email
$email = $parsedMsg[0];
if(count($parsedMsg) > 1){
$photo = $parsedMsg[1];
}
$noEmailFlag = 0;
} else if (strpos($parsedMsg[1], '@') !== false){
$email = $parsedMsg[1];
$photo = $parsedMsg[0];
$noEmailFlag = 0;
}
else {
$noEmailFlag = 1;
}*/
/*$fp = fopen("data.txt", "a");
fwrite($fp, ($_REQUEST['From']. " said " . $message . "\r\n"));
//fwrite($fp, "\n";
fclose($fp); */
//$photo = '3'; //hardcoded for testing
$fields = array(
'access_token' => 'da30fea964c5ec5004f2fae056100fa924887b46',
'args' => $message,
);
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
//if ($noEmailFlag == 0) {
$response = http_post_fields("https://api.spark.io/v1/devices/".$coreID."/message", $fields);
echo "<Response>";
echo "<Sms>Look up!</Sms>";
echo "</Response>";
//}
/*else if ($noEmailFlag == 1) {
echo "<Response>";
echo "<Sms>I'm sorry, I didn't catch your email... would you please send your message again, including your email? Your photos want to see you, too!</Sms>";
echo "</Response>";
}*/
?>