Developer Infrastructure Guide

Telecom Integration,
Simplified for Engineers & Beginners.

A complete high-level architectural story and code-level reference for the 9 core PHP scripts driving BDApps OTP, Subscription, USSD, and Webhook services.

09
Core PHP Scripts
04
Telco Channels
100%
JSON RESTful API
OTP/USSD
Session Handling
01

Credential Initialization

config.php

Stores application secret credentials (BDAPPS_APP_ID and BDAPPS_APP_PASSWORD). Every endpoint script includes this file to authenticate outgoing cURL requests to BDApps servers.

Analogy: The master security keycard given to your server so BDApps telecom gateways recognize your application.
02

OTP Dispatch Request

send_otp.php

Receives the subscriber's phone number, normalizes it into international telecom format (tel:88017...), and triggers an SMS PIN request to BDApps. BDApps returns a unique referenceNo.

Analogy: Registering at a desk; the system dispatches a verification passcode to your phone and hands you a tracking receipt.
03

OTP Verification & Subscription

verify_otp.php

Validates the user's input PIN against the issued referenceNo via BDApps OTP Verification API. Upon match, the subscriber is registered and billing commences.

Analogy: Entering the received passcode along with your receipt to confirm membership enrollment.
04

Subscription Status Query

check_subscription.php

Queries the BDApps getStatus endpoint to verify if a subscriber is currently REGISTERED or UNREGISTERED.

Analogy: An automated digital membership check at entrance verifying active payment standing.
05

Unsubscription Processing

unsubscribe.php

Dispatches an unsubscription directive (action: 0) to BDApps, deactivating recurring daily/weekly charges for the subscriber.

Analogy: Submitting a formal cancellation request to immediately stop recurring billing.
06

Inbound / Outbound SMS

sms.php

Handles Mobile Originated (MO) SMS webhooks sent by BDApps when subscribers text the application shortcode, logs data to sms_log.txt, and transmits a Mobile Terminated (MT) reply.

Analogy: Receiving a text message from a user, logging it into the system ledger, and dispatching an immediate SMS reply.
07

Interactive USSD Menus

ussd.php

Manages USSD session dialogues (*123#). Renders interactive option menus for registered users or prompts pop-up subscription dialogs for non-registered users.

Analogy: An interactive automated display menu on feature phones.
08

Asynchronous Webhook Listener

subscription_listener.php

Listens for real-time background notification callbacks triggered by BDApps (e.g. daily auto-renewals or SMS cancellations) and appends events to subscription_notifications.log.

Analogy: An automated bank receipt generator recording all background billing events.
09

Core SDK Engine

sdk_file.php

Contains foundational OOP helper classes: Core, SMSSender, SMSReceiver, UssdSender, UssdReceiver, Subscription, DirectDebitSender, and Logger.

Analogy: The underlying engine framework encapsulating raw cURL operations and protocol formatting.
MODULE 01

Configuration

Centralized credentials and constants declaration.

config.php
MODULE 02

OTP Dispatch

Mobile normalization and OTP request handling.

send_otp.php
MODULE 03

OTP Verification

Reference validation and subscription activation.

verify_otp.php
MODULE 04

Status Monitoring

Live getStatus querying for mobile numbers.

check_subscription.php
MODULE 05

Deactivation

Unsubscription payload delivery to BDApps.

unsubscribe.php
MODULE 06

SMS Gateway

MO receiver and MT auto-response handler.

sms.php
MODULE 07

USSD Engine

Interactive USSD session dialogue manager.

ussd.php
MODULE 08

Event Webhook

Asynchronous subscription callback logger.

subscription_listener.php
MODULE 09

Core SDK

OOP abstractions, cURL client, & exception handlers.

sdk_file.php
config.php 71 B

Stores environment Application ID and Password constants.

define('BDAPPS_APP_ID', ''); define('BDAPPS_APP_PASSWORD', '');
send_otp.php 2.7 KB

Normalizes 11-digit MSISDN and requests OTP generation.

$subscriberId = 'tel:88' . $digits; // POST -> /subscription/otp/request
verify_otp.php 1.7 KB

Verifies OTP pin against issued reference number.

// POST -> /subscription/otp/verify // Returns statusCode: S1000 on success
check_subscription.php 2.1 KB

Queries active subscription state for a subscriber ID.

// POST -> /subscription/getStatus // Response: isSubscribed boolean
unsubscribe.php 2.3 KB

Issues action=0 payload to revoke subscription.

$requestData = ['action' => '0', ...]; // POST -> /subscription/send
sms.php 765 B

MO SMS receiver and MT reply handler using SMSSender.

$receiver = new SMSReceiver(); $sender->sms('MT: ...', $address);
ussd.php 1.3 KB

Manages interactive USSD sessions and dialogue flows.

$ussdSender->ussd($sessionId, 'Menu', $address);
subscription_listener.php 592 B

Asynchronous event webhook handler logging callbacks.

file_put_contents('subscription_notifications.log', ...);
sdk_file.php 18.5 KB

Core SDK classes containing cURL, logging, and models.

class Core { ... } class SMSSender extends Core { ... }
Endpoint File Method Payload Parameters Expected JSON Response
/send_otp.php POST user_mobile {"success":true, "referenceNo":"..."}
/verify_otp.php POST Otp, referenceNo {"statusCode":"S1000", "subscriptionStatus":"REGISTERED"}
/check_subscription.php POST user_mobile {"isSubscribed":true, "subscriptionStatus":"REGISTERED"}
/unsubscribe.php POST user_mobile {"success":true, "subscriptionStatus":"UNREGISTERED"}
/sms.php POST BDApps MO JSON Stream {"statusCode":"S1000", "statusDetail":"Process completed successfully."}
/ussd.php POST BDApps USSD Session JSON {"statusCode":"S1000", "statusDetail":"Success"}
/subscription_listener.php POST BDApps Notification JSON {"statusCode":"S1000", "statusDetail":"Notification received"}