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

14 responses to “Sample GP SMS API Use With PHP

  1. I’ve approved your comment on my site. Just replaced your fake details with your original data. Be brave to comment if you have any logical reason.

    I don’t know what you mean by stealing but I must say “code re-use” is one of the key policies of the open source movement.

    By the way, if you look carefully at my codes, you’ll see that it’s quite different than the sample code posted on the AloAshbei forums. They have demonstrated LBS API where as I’ve implemented the SMS API.

    By the way, it was nice to meet you. Have a nice time!

    • What the hell are you talking about? I haven’t commented or even visited your site before today.

      And about code re-use, anybody can re-use my code. There is no copyright here which says you can’t re-use. In fact, you are free to do anything with the code. I am a HUGE FAN of open source movement, and most of the soft I use are open source.

      And fyi, I don’t need to be afraid of anything. I was hurt by your comment.

      • Okay buddy. No problem. But remember one thing, I am on a self hosted WP. I can track IP address. Just after you posted that comment another user with the same details tried to impostor me.

        Nice to know it was not you. Let’s forget about that mother fu**ing idiot. Thanks for clearing things up.

  2. Are u sure the last comment(which you assumed as mine, which you haven’t published, i guess) is from me? Please check the HTTP_X_FORWARDED_FOR server variable and make sure that the message has the same ip forward list as mine, else don’t accuse me again, please. It’s really embarrassing.

    And also you haven’t done anything with the 2nd comment of your blog which you assumed as mine. I hope a simple ip list check will make it clear.

    Hope, I have make myself clear. Still if you ain’t convinced and want to accuse me again than I have nothing to say except “STOP ACCUSING ME FOR NO REASON”.

    • I trust people. I am not accusing you. I just warned you someone is doing this. And it was quite surprising that s/he was monitoring my site. It was too quick for him/her to post a comment right after you. Looks like this person has some sort of likeness towards you 🙂

Want to share your views? Please do reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s