Sample GP SMS API Use With PHP

Below there is a sample code of using GP SMS Api with PHP.

<?php
function send_sms($mobile_no, $text) {
//creating a soap client
$soap=new SoapClient(“SMS WSDL.wsdl”);
//setting the variables of SendSMSRequest type
$req_vars=array(
“registrationID”    =>  “YOUR USER ID”,
“password”          =>  “YOUR PASSWORD”,
“sourceMsisdn”      =>  “88017********”,
“destinationMsisdn” =>  “88”.$mobile_no,
“smsPort”           =>  7424,
“msgType”           =>  4,
“charge”            =>  0.00,//If you want you can give some value, but if you are charged, I’m not responsible for that 😛
“chargedParty”      =>  “88017********”,
“contentArea”       =>  “gpgp_psms”,
“msgContent”        =>  $text,
);
//The request variable
$request=array(“SendSMSRequest”=>$req_vars);
//requesting now to send sms
$response=$soap->sendSMS($request);
return $response;
}

?>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″>
<title>GP SMS Api Testing</title>
</head>
<body>
<pre>
<?php
//calling the function
$phone_no=”017********”;
$text=”Hi people! Just testing out! :-)”;
$response=send_sms($phone_no, $text);
print_r($response);
?>
</pre>
</body>
</html>

P.S. : If you get any SSL related error, go to your php.ini file,find out

“;extension=php_openssl.dll”

then delete the ; from the beginning

Update : A new updated post (with updated code) in this link: http://blog.muktosource.com/enzam/send-sms-example-with-gp-aloashbei-api-php.html

Advertisements