-
Notifications
You must be signed in to change notification settings - Fork 25
/
sms.php
executable file
·43 lines (33 loc) · 1.27 KB
/
sms.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
<?php
// Be sure to include the file you've just downloaded
require_once('AfricasTalkingGateway.php');
// Specify your login credentials
$username = "WeloveNerds";
$apikey = "990aba1dad3aeefa0be75b70a0c961586f682d72866b5d6d0370e5ddfbffa443";
// Specify the numbers that you want to send to in a comma-separated list
// Please ensure you include the country code (+254 for Kenya in this case)
$recipients = "+254787235065";
// And of course we want our recipients to know what we really do
$message = "It is good to be awake at this time";
// Create a new instance of our awesome gateway class
$gateway = new AfricasTalkingGateway($username, $apikey);
// Any gateway error will be captured by our custom Exception class below,
// so wrap the call in a try-catch block
try
{
// Thats it, hit send and we'll take care of the rest.
$results = $gateway->sendMessage($recipients, $message);
foreach($results as $result) {
// status is either "Success" or "error message"
echo " Number: " .$result->number;
echo " Status: " .$result->status;
echo " MessageId: " .$result->messageId;
echo " Cost: " .$result->cost."\n";
}
}
catch ( AfricasTalkingGatewayException $e )
{
echo "Encountered an error while sending: ".$e->getMessage();
}
// DONE!!!
?>