-
-
Save drizzentic/18522c06e4529c58bc82fefe429e319b to your computer and use it in GitHub Desktop.
<!-- MIT License | |
Copyright (c) 2016 Derrick Rono | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all | |
copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
SOFTWARE. --> | |
<?php | |
#We obtain the data which is contained in the post url on our server. | |
$text=$_GET['USSD_STRING']; | |
$phonenumber=$_GET['MSISDN']; | |
$serviceCode=$_GET['serviceCode']; | |
$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 | |
$data=array( | |
'phonenumber'=>$phonenumber, | |
'fullname' =>$level[0], | |
'electoral_ward' => $level[1], | |
'national_id'=>$level[2] | |
); | |
$response="END Thank you ".$level[0]." for registering.\nWe will keep you updated"; | |
} | |
header('Content-type: text/plain'); | |
echo $response; | |
} | |
?> | |
am new in this and i want to test the code
where do i see "open postman client"
Come on man...this is a sham!
That wont give you such an interface on your phone that is a blueprint.
How can i go back to the previous level?
e.g: If an user is on level 3 and he wants to go to level 2 without quitting the current session.
How can be this done?
how can i get this code and run it?
To help you guys run the code please try to use Africa's talking API https://africastalking.com/
It helped me
Thanks man
I appreciate this. It's simple example to start with USSD.
Come on man...this is a sham!
That wont give you such an interface on your phone that is a blueprint.
@DavidInnocent You should have read the title of the gist.
Code is fine. will it work on gsm phones? Could you please guide me step by step to build application which we can run on old phones
This is a good start thanks
how can add a back button option in this ussd
Thank you for this!
is it working on kannel open source gatway
Thank you so much
Thank you
Thanks buddy for your assistance. I was figuring out how to start learning USSD codes.