-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsms.php
More file actions
57 lines (36 loc) · 1.38 KB
/
Copy pathsms.php
File metadata and controls
57 lines (36 loc) · 1.38 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
<?php
require('AfricasTalkingGateway.php');
require('dbConnector.php');
require('config.php');
// get post via AfricasTalkingGateway API
$from = $_POST['from'];
$to = $_POST['to'];
$text = trim($_POST['text']);
$date = $_POST['date'];
$id = $_POST['id'];
$linkId = $_POST['linkId'];
if (isset($from)){
$stmt = $db->query("SELECT * FROM message_table WHERE phone_number = '{$from}' AND adm='{$text}' ORDER BY date_posted asc LIMIT 1");
$stmt->execute();
if($stmt->rowCount() > 0){
foreach($stmt->fetchALL(PDO::FETCH_ASSOC) as $row){
$date_posted=$row['date_posted'];
$phpdate=strtotime($date_posted);
$new_date=date("d/m/Y", $phpdate);
//Respond with Fee Balance
$message="Fee Balance for " .$row['student_name']." as at " .$new_date." is Ksh.".$row['fee_balance']."\n";
}
}
else{
$message= "Fee Balance not available at the moment\n" ;
}
try{
$recipients = $from;
$gateway= new AfricasTalkingGateway($username, $apikey,"sandbox");
$gateway->sendMessage($recipients,$message,"25551");
}
catch(AfricasTalkingGatewayException $e){
echo $e->getMessage();
}
}
?>