1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
<?php
//initialize the request variable
$request = "";
$param["username"] = "admin";
//le mot de passe
$param["password"] = "omdm";
//le message à envoyer
$param["text"] = "This is sample message.";
//numero de destination
$param["to"] = "64064844";
//recupération des paramètre dans un tableau
foreach($param as $key=>$val){
$request.= $key."=".urlencode($val);
//append the ampersand (&) sign after each paramter/value pair
$request.= "&";
}
//remove the final ampersand sign from the request
$request = substr($request, 0, strlen($request)-1);
//this is the url of the gateway's interface
$url = "http://172.16.30.246:13013/cgi-bin/sendsms";
//initialize curl handle
$ch = curl_init;
curl_setopt($ch, CURLOPT_URL, $url); //set the url
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); //return as a variable
curl_setopt($ch, CURLOPT_POST, 1); //set POST method
curl_setopt($ch, CURLOPT_POSTFIELDS, $request); //set the POST variables
$response = curl_exec($ch); //run the whole process and return the response
curl_close($ch); //close the curl handle
//show the result onscreen for debugging
//print $response;
?> |
Partager