Receive SMS Sample Code

Sample 2way SMS Code

Sample code for an eBanking SMS application using the 2way SMS API.

<?php

/*
* Read HTTP POST values
*/

$sms_from = $_POST['sms_from']; 
$sms_to = $_POST['sms_to'];
$sms_message = trim($_POST['sms_message']);


/*
* Below is the business logic based on the response of the user.
* You can pass this to your database, internal system etc.
*/

switch ($sms_message) {
    case 1:
        $option = "Card";

        break;
    case 2:
        $option = "Bank Account";

        break;
    case 3:
        $option = "Wallet";

        break;
    default:
        $option = "NONE";
}

/*
* Depending on the 2way SMS operation category, send a corresponding 
* response message back to the subscriber.
*/

if($option == "NONE"){
    $output['sms_message'] = "Welcome to HollaTags' eBanking.\nPlease select your payment channel.\n1) Card\n2) Bank Account\n3) Wallet";
}else{
    $output['sms_message'] = "You selected *{$option}*. Thank you.";
}

/*
* You do not need to define $sms_from or $sms_to in your response
* Your sms_message will by default go to the session $sms_to.
*/

echo json_encode($output); 

exit;

Last updated

Was this helpful?