Created
December 26, 2014 16:07
-
-
Save pasindud/737421b81eee6b9ca262 to your computer and use it in GitHub Desktop.
Ideamart USSD Snippet
This file contains hidden or 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
| <?php | |
| $url="http://localhost:7000/ussd/send"; | |
| sendUSSD($url,"APP_001","password","Hello World","tel:94771231234","1","mt-cont","440"); | |
| function sendUSSD($url,$appid,$password,$message,$address,$seesionid,$ussdOperation,$encoding) | |
| { | |
| $arrayField = array("applicationId" => $appid, | |
| "password" => $password, | |
| "message" => $message, | |
| "destinationAddress" => $destinationAddress, | |
| "sessionId" => $sessionId, | |
| "ussdOperation" => $ussdOperation, | |
| "encoding" => $encoding | |
| ); | |
| $ch = curl_init($url); | |
| curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
| curl_setopt($ch, CURLOPT_POST, 1); | |
| curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($req)); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| $res = curl_exec($ch); | |
| curl_close($ch); | |
| return json_decode($res); | |
| } | |
| function recieveUSSD(){ | |
| $req = json_decode(file_get_contents('php://input')); | |
| $res = array('statusCode'=>'S1000','statusDetail'=>'Process completed successfully.'); | |
| header('Content-type: application/json'); | |
| return json_encode($res); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment