USSD menu with PHP

885 views
Skip to first unread message

Muhammad Salao

unread,
Nov 29, 2017, 11:59:18 AM11/29/17
to restcomm
Hi everyone

I'm new and i recently installed Restcomm USSD Gateway version 7.0.41 locally on my machine and i successfully run the ussd demo test application which is build using JAVA.
Now i want to run a simple USSD example which shows a menu build with PHP but after many attemps i was not able to do it. Can i have an example of PHP USSD application for Restcomm USSD Gateway. I attached my php application

Thank you

menu.php

Muhammad Salao

unread,
Dec 11, 2017, 9:14:19 AM12/11/17
to restcomm
Hi everyone,

My problem is solved.

Thank you

Yorgos Saslis

unread,
Dec 11, 2017, 9:26:23 AM12/11/17
to restcomm
Hello Muhammad!

Wow - that's great news! Glad to hear you've solved the problem! 
Would you mind sharing in a little more detail what the issue was and how you managed to overcome it? 

Future users could really benefit from this.  ; )

Thanks in advance, 
Yorgos

Muhammad Salao

unread,
Dec 13, 2017, 6:11:30 AM12/13/17
to restcomm
Hello Yorgos!

I was able to solve my problem by reading in the documentation the part that explains the http mechanism in the case of an http pull request.

Fortunately there is a ussd application that comes with the default gateway.
So with Wireshark I was able to capture the traffic between the ussd application and the gateway. And I noticed that whatever the language used the gateway only includes xml.


Without talking too much, let's try to create an application that returns the number of a subscriber

1. We need to retrieve the xml request sent by the ussd gateway for example $dataPost = file_get_contents ('php: // input');

2. To be able to process the received information better, we use simplexml_load_string ($postData);

3. We retrieve the subscriber's phone number
$number = $xml-> processUnstructuredSSRequest_Request-> msisdn ['number'];

4. We create a simple menu
$menu = "Welcome this is your number $number;

5. Then a variable containing the xml and the number to send to the ussd gateway
$result = '
<? xml version = "1.0" encoding = "UTF-8"?>
<dialog type = "End" appCntx = "networkUnstructuredSsContext_version2" networkId = "0" localId = "20" remoteId = "15" mapMessagesSize = "1" customInvokeTimeout = "25000" returnMessageOnError = "false">
<localAddress pc = "2" ssn = "8">
<ai value = "67" />
</ LocalAddress>
<remoteAddress pc = "0" ssn = "8">
<ai value = "18" />
<gt type = "GlobalTitle0100" tt = "0" es = "2" np = "1" nai = "4" digits = "9960639902" />
</ RemoteAddress>
<unstructuredSSRequest_Request invokeId = "0" dataCodingScheme = "15" string = "'.$menu.'" />
</ Dialog> ';

You will have more information about the tags in the documentation of the ussd gateway

6. And finally we display the result
echo $result;

You just have to include all this in php tags and voila

I hope I helped and i have another question.


During an exchange between a subscriber and the ussd gateway, a session must be maintained with a unique session number. Which of the ussd application or gateway should create the session id?

Thank you.
Reply all
Reply to author
Forward
0 new messages