Simple Steps To Create USSD Application For Your Website


Hi Guys, here today We've a very useful and searching articles for You Guys. You know, Sometimes or maybe all the time it is very hard to explain the technical concepts in a human’s understanding Language. Most of the explanations, a 2 year old human can't even relate to. Today We will try to disclose to You Guys opporturned in reading this as low as We can to tell a full or short story about the USSD technology. By now We're getting a bit technical, but chill and assume everything is well going. We can't just dive into the main point for You must know the main concept that compile this. Firstly, You must know this [USSD].

What is USSD/What Your understanding about USSD?

Whele, lets to our knowledge in what we can offer here concerning this Question. On a normal and daily basis we have many things we interact with but we have actually never known their real name. Today we gonna use USSD as a case study which is, is also one of them. Now, lets look at what Wikipedia states this [USSD] to be..... According to Wikipedia which said USSD >

U> Unstructural
S> Supplementary
S> Service
D> Data

which is a global system for mobile to communicate directly with a program sitting on the service providers(MTN, Safaricom, Airtel, Orange and many unknowned) computers. If You find it difficult to understand this, We need You to think of any operation You perform on Your phone which is not sms, internet or making calls. Let’s use this as a case study. Checking credit or buying bundles. We all agree that this process normally required You to hit some of Your keys in Your mobile Phone, right? Like something like this [*144# , *131*2# or *544#] When you dial the above numbers you will get a prompt option giving You either data or instructions to follow to get respective services.

The screen bellow shows as sample of a user requesting USSD request .


I believe by now You can now relate to what is disscussing here. Now We jump straight and explain the magic that happens for this to be able to take happen..
So basically what happens is this:
When users dials a provided USSD code.
This request is tranffers to the mobile service provider.
The service provider routes the request from a gateway to the machine that host the application.
The application process the requests from which its received from the service provider and sends back feedback.
The feedback is processed by the provider and sent back to the mobile phone.

Now, We will explain shortly or much as You take it serious determine Your success. How to create a USSD application for Your blog/websites. The magic behind USSD For the spell to be successful you will need a magic wand which has several components the bellow:

*> Postman Client for Chrome
*> Running web server ( Xammp, LAMP. etc)
*> Sublime text editor
*> Brain
*> Cup of coffee (several) *smile*

Also Read :- Simple steps to setup WAPKIZ DNS 

Ensure You have the above materials and when You satisfy the above requirements, You're now good to go to write and execute the spell.
NOTE :- That for this tutorial we are not going to use a live gateway but just simulate the way it would happen in the real environment. Thanks for You understanding.....

Also Read :-  How To Make Facebook Phising From The Scratch

SPELL 1 :- To develop for USSD their are key things you need to understand. Some of them are basic programming skills which include, Switch statements,conditional statements, etc.
This is as a result doing a lot of string manipulation to extract data and interpret the request sent to us by the USSD gateway. One thing You should not forget is this, the USSD gateways speak different languages i.e send strings with different naming.
For this tutorial we are going to adapt the following as our sample request parameters.

‘MSISDN’ => ‘254714611388’, (phone number sending the request)

‘SESSION_ID’ => ‘355562002’,(Session incase you need to perform audits)

‘USSD_STRING’ => ‘58*1234*456*252’, (This the string that contains the requests sent from the USSD gateway, basically it is the answers the user give when prompted on the phone.)

All the answers (data entered by user on mobile phone) are been separated by "*" and every answer the user enters is concatenated to the existing string. So, in this, You need to be conversant with explode() function for php.

SPELL 2 :- This spell will lead You to main point here. Which involve creating a sample php code to emulate and run a process. One very main important thing You must know in USSD is the use of keyword CON and END.
CON keyword is used when implying to a continuous request. For example when you expect a user to enter an answer.
END is used to terminate the USSD session. When you append this at the beginning of you script, it will tell the provider that the session has ended and thus user is not given an input box afterwards but rather an ‘ok’ or ‘exit’.

Below is an example of the php code which is also commented to make it easier understand what is happening.

#We obtain the data which is contained in the post url on our server.
$level = explode("*", $text);
if (isset($text)) {
if ( $text == "" ) {
$response="CON Welcome to the registration portal.\nPlease enter you full name";
if(isset($level[0]) && $level[0]!="" && !isset($level[1])){
$response="CON Hi ".$level[0].", enter your ward name";
else if(isset($level[1]) && $level[1]!="" && !isset($level[2])){
$response="CON Please enter you national ID number\n";
else if(isset($level[2]) && $level[2]!="" && !isset($level[3])){
//Save data to database
'fullname' =>$level[0],
'electoral_ward' => $level[1],
$response="END Thank you ".$level[0]." for registering.\nWe will keep you updated";
header('Content-type: text/plain');
echo $response;

SPELL 3 :- Thumbs Up if You have endured to this point. The third spell will help us know whether our code is working or not. So to test the code download it from from > https://gist.github.com/drizzentic/18522c06e4529c58bc82fefe429e319b
and follow the bellow GUILDDS :-

FIRST GUILD :- Go on by Placing the the code in Your webserver folder in "htdocs or /var/www/html" and open postman client
include the url to where the code is hosted e.g localhost add the parameters specified in SPELL 1 to the request url e.g
Note that the USSD string should be empty for You to see the welcome page.
send the request and check postman response window for the response from the server. e.g this represent the feedback the user gets on their mobile phone when the make a request.

SECOND GUILDS :- Modify the USSD string by adding Your name example,
http://localhost:9000?MSISDN=07062492630&USSD_STRING=Joel Anthony&serviceCode=*144#
Different prompt will come. To proceed to the next step put a ‘*’ after Your name to act as the separator. Do this for the rest of the prompts until you reach the end. Example,
http://localhost:9000?MSISDN=07062492630&USSD_STRING=Joel Anthony*Nairobi&serviceCode=*144#
The above process or guilds will come in handy when You're developing/creating USSD applications. Testing on the live environment is very costly, so before you can get a testbed to test, stick to postman.

That's all... Please show more love by sharing this to friends, state Your comment either confuse or testimonies. THANK YOU!
Technology 1826709901935482446

Post a Comment


Home item

Must Read

Subscribe to Our Youtube Channel

Random Posts