Last active
January 27, 2022 10:54
-
-
Save JaniKibichi/3a8f39177d46b705f5336f127d447bd2 to your computer and use it in GitHub Desktop.
What you have on the callback.
This file contains 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 | |
$Sender = $_POST['from']; | |
$to = $_POST['to']; | |
$text = $_POST['text']; | |
$date = $_POST['date']; | |
$id = $_POST['id']; | |
$linkId = $_POST['linkId']; //This works for onDemand subscription products | |
//Sending Messages using sender id/short code | |
if(!empty($_POST['from'])){ | |
require_once('AfricasTalkingGateway.php'); | |
$username = "you"; | |
$apikey = "68c993a2f1780b4bcd60323b994167534da487ba54109367f82532541636e9"; | |
$recipients = $Sender; //this is the client who has just send in the SMS and you are Autoreplying. | |
$message = "Thanks for coming. Far too kind. I'm a lumberjack and its ok, I sleep all night and I work all day"; | |
// Specify your AfricasTalking shortCode or sender id | |
$from = "88000"; | |
$gateway = new AfricasTalkingGateway($username, $apikey, "sandbox"); | |
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