Skip to content

Instantly share code, notes, and snippets.

@ianjuma
Last active February 28, 2017 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianjuma/129cdf1b109faf4f678cf4de737e0850 to your computer and use it in GitHub Desktop.
Save ianjuma/129cdf1b109faf4f678cf4de737e0850 to your computer and use it in GitHub Desktop.
<?php
$from = $_POST['from'];
$to = $_POST['to'];
$text = $_POST['text'];
$date = $_POST['date'];
$id = $_POST['id'];
$linkId = $_POST['linkId'];
if(!empty($_POST['from'])) {
require_once('AfricasTalkingGateway.php');
$username = "user";
$apikey = "api_key";
$message = "Great test Brian";
// Specify your AfricasTalking shortCode or sender id
$shortCode = "22384";
$gateway = new AfricasTalkingGateway($username, $apikey);
$options = array(
'keyword' => "yes",
'linkId' => $linkId
);
try
{
$results = $gateway->sendMessage($from, $message, $shortCode, 0, $options);
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