-
Notifications
You must be signed in to change notification settings - Fork 0
/
insms.php
44 lines (37 loc) · 1.33 KB
/
insms.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
<?php
// STEP 1
// incoming request parameters
$keyword = $_GET["keyword"]; // first word
$from = $_GET["from"]; // the sms sender
$text = $_GET["text"]; // the remaining text after the first word
$timestamp = time();
// STEP 2
// build your logic on how to respond the incoming request
switch($keyword){
case "apisms":
$reply = "You (". $from .") have been subscribed to campaign one";
break;
case "two":
$reply = "You (". $from .") have been subscribed to campaign two";
break;
default:
$reply = "Invalid campaign name";
break;
}
// STEP 3
// may be you need to save the request to your own database
// @optional
mysql_connect("localhost", "username_sms", "####");
mysql_select_db("username_sms");
mysql_query("insert into smsinput
(`from`, `keyword`, `text`, `timestamp`)
values ('".mysql_real_escape_string($from)."',
'".mysql_real_escape_string($keyword)."',
'".mysql_real_escape_string($text)."',
'".$timestamp."'
)");
// STEP 4
// send reply back to Sparrow SMS
// This has to be STRICTLY 160 chars (max)
die($reply);
?>