USSD Menu Example Code (PHP)
USSD Menu Example Code (PHP)
<?php
//Change the trigger string to trigger on custom text, the text is case insensitive.
$ussd_trigger_str = 'start ussd';
//If the get contains the "model" parameter start a new ussd session
if( array_key_exists( 'model', $_GET ) )
{
//START USSD SESSION
$dest_MSISDN = $_GET['originator'];
$msg_content = $_GET['msg'];
$sessionid = uniqid();
//Create xml to start the USSD session
$xmlstr = "<?xml version='1.0' ?>\n". "<umsprot></umsprot>";
$headers = array(
"POST ".USSD_URL." HTTP/1.0",
"Content-type: application/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Content-length: ".strlen($xml_data)
);
if( ! $sent )
{
$error = curl_error( $curl );
}
}
}
else
{
curl_close( $curl );
exit();
= $requestXML->xpath( '/umsprot/*[1]' );
= $functionNode[0]->getName();
$functionNode_attributes = $functionNode[0]->attributes();
$seesionId = $functionNode_attributes['sessionid'];
//Different functions to take action on
switch( $functionName )
{
case "open_session":
$message = $questions_array[0];
"<umsprot></umsprot>";
echo $root->asXML();
exit();
break;
case "abort_session_req":
}
?>