Created
September 11, 2014 08:42
-
-
Save pasindud/1f1f8078ca504ce3d129 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reciveUssd() { | |
$array = json_decode(file_get_contents('php://input'), true); | |
if (!((isset($array['sourceAddress']) && isset($array['message'])))) { | |
throw new Exception("Some of the required parameters are not provided"); | |
} else { | |
$responses = array("statusCode" => "S1000", "statusDetail" => "Success"); | |
header("Content-type: application/json"); | |
echo json_encode($responses); | |
} | |
} | |
function sendUssd($server,$applicationId,$password,$destinationAddress,$message,$sessionId,$ussdOperation){ | |
$arrayField = array("applicationId" => $applicationId, | |
"password" => $password, | |
"message" => $message, | |
"destinationAddress" => $destinationAddress, | |
"sessionId" => $sessionId, | |
"ussdOperation" => $ussdOperation, | |
"encoding" => "440" | |
); | |
$ch = curl_init($server); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($arrayField)); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$res = curl_exec($ch); | |
curl_close($ch); | |
return $res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment