Lesson 13: USSD Parameters and USSD Menu

USSD Parameters  

There are four USSD parameters. 

  1. MSISDN
  2. SESSION ID
  3. SERVICE CODE
  4. USSD STRING or USER RESPONSE

MSISDN is an equivalent of a mobile phone number. It stands for Mobile Station International Subscriber Directory Number and must be unique for every mobile station.

SESSION ID is a unique ID that a USSD gateway generates to uniquely identify the session while it is active before it expires. Remember USSD is session oriented. 

SERVICE CODE is the number given to users for them to access a USSD application. For example in *123#, 123 is the service code.

USSD STRING or USER RESPONSE is what the user replies with while using the application. For example if a user dials *123# and gets this menu

1.  Login
2 . Register

So, when the user replies with a 2 to register, the 2 is treated as a USSD STRING OR USER RESPONSE.

N/B: It is worth noting that the names provided as parameters are not standard, you will need to go through gateway documentation to know how they are labelled. 

Now, lets assume that your host server, local host, is called localhost and has a PHP file ‘ucuresults.php’ in folder ‘ussdapp’.

The callback URL will be something like http://localhost/ussdapp/ucuresults.php or https://localhost/ussdapp/ucuresults.php for secure http. 

When a user sends a request say *123# the gateway will append the USSD parameters as URL queries and then point to the hosting server. This means you must be able to receive the query parameter values.  What is sent to server looks something like this

http://localhost/ussdapp/ucuresults.php?serviceCode=*123%23&sessionId=1234DD34&MSISDN=0726172579&text=1 

Receiving the USSD Parameters 

The PHP $_GET method is used to receive values sent from the server. From the above URL the code snippet below shows how to get the values. 

<?php
$phonenumber = $_GET['MSISDN'];
$sessionID = $_GET['sessionId'];
$servicecode = $_GET['serviceCode'];
$ussdString = $_GET['text'];">?>

N/B: Note that every gateway or USSD api work differently; for example some uses HTTP get body, HTTP post or TCP packets to carry required data.

Note that your role of is to give the USSD gateway a callback URL e,g http://localhost/ussdapp/ucuresults.php and it will take care adding the parameters. Remember that localhost is the server that hosts the code.

I hope this post has helped you understand about USSD parameter. In the next lesson, we are going to look at USSD menus

Do not shy off leaving a comment 

20 Comments
    • Derdus Kenga
    • Derdus Kenga
    • Derdus Kenga
        • Derdus Kenga
        • Derdus Kenga
  1. Derdus Kenga

Add a Comment

Your email address will not be published. Required fields are marked *