Created
November 16, 2015 12:50
-
-
Save Leeibrah/dbc5b78d096c528d173c to your computer and use it in GitHub Desktop.
SMS Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Sending Messages using sender id/short code | |
require_once('AfricasTalkingGateway.php'); | |
$username = "leeibrah"; | |
$apikey = "fcaf954b3d76c362378af7185068142cab35de9284e4371234d945bc324227aa"; | |
// $recipients = "+254711XXXYYY,+254733YYYZZZ"; | |
$recipients = "+254714019079"; | |
$message = "Testing Shared M Shamba Application."; | |
// Specify your AfricasTalking shortCode or sender id | |
$from = "20880"; | |
$gateway = new AfricasTalkingGateway($username, $apikey); | |
try | |
{ | |
$results = $gateway->sendMessage($recipients, $message, $from); | |
foreach($results as $result) { | |
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!!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment