Skip to content

Instantly share code, notes, and snippets.

@Leeibrah
Created November 16, 2015 12:50
Show Gist options
  • Save Leeibrah/dbc5b78d096c528d173c to your computer and use it in GitHub Desktop.
Save Leeibrah/dbc5b78d096c528d173c to your computer and use it in GitHub Desktop.
SMS Code
<?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