-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsms.php
35 lines (27 loc) · 878 Bytes
/
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
<?php
require 'vendor/autoload.php';
use AfricasTalking\SDK\AfricasTalking;
// Set your app credentials
$username = "sandbox";
$apiKey = "24910cf47ea9bf7979692860deb450ec0773019b0000668a7a583fb712d8cb98";
// Initialize the SDK
$AT = new AfricasTalking($username, $apiKey);
// Get the SMS service
$sms = $AT->sms();
// Set the numbers you want to send to in international format
$recipients = "+18763448991";
// Set your message
$message = "I'm a lumberjack and its ok, I sleep all night and I work all day";
// Set your shortCode or senderId
$from = "develop3r";
try {
// Thats it, hit send and we'll take care of the rest
$result = $sms->send([
'to' => $recipients,
'message' => $message,
'from' => $from
]);
print_r($result);
} catch (Exception $e) {
echo "Error: ".$e->getMessage();
}