HollaTags API
  • Introduction
  • 📳SMS
    • Send
    • Receive
    • Status
    • Credit
    • Lookup
    • Send SMS Sample Code
    • Receive SMS Sample Code
    • API Response
    • Callback
    • OTP
    • SMS DLR Error Codes
  • 📳USSD
    • USSD Inbound
    • USSD Outbound
    • USSD Sample Code
    • USSD Error Codes
  • 📳WhatsApp
    • WhatsApp Chat
    • WhatsApp Push
    • WhatsApp Sample Code
  • 📳SMPP
    • SMPP Specification
    • SMPP Servers
    • SMPP Authentication
    • SMPP Configuration
    • SMPP Message PDU
    • SMPP Client Configuration
    • SMPP Response Codes
    • SMPP DLR Codes
  • 💳Airtime
    • Airtime (VTU)
  • ❓FAQ
    • USSD - Dedicated
    • USSD - Shared
Powered by GitBook
On this page

Was this helpful?

  1. WhatsApp

WhatsApp Sample Code

PreviousWhatsApp PushNextSMPP Specification

Last updated 4 years ago

Was this helpful?

Sample WhatsApp Menu Code

Sample code for an eBanking application using .

<?php

/*
* Read HTTP POST values
*/

$whatsapp_from = $_POST['whatsapp_from']; 
$whatsapp_to = $_POST['whatsapp_to'];
$whatsapp_message = trim($_POST['whatsapp_message']);


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

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

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

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

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

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

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

/*
* You do not need to define $whatsapp_from or $whatsapp_to in your response
* Your whatsapp_message will by default go to the session $whatsapp_to.
*/

echo json_encode($output); 

exit;

📳
WhatsApp Chat API