How to send SMS from mysmsmantra using php?

I have purchased API from smsmantra.Can anyone tell me how to integrate this in website.My web application is in PHP language.

Junior Developer Asked on November 12, 2018 in TECHNOLOGY.
Add Comment
1 Answer(s)

Here is the code.It’s working for me.Hope it will help you.

<?php if ($_REQUEST['smsnumber'] != "") {

$company_data['sms_text']="This is for testing purpose";

$TID="TXN".rand();
$number = $_REQUEST['smsnumber'];

$text = "Dear Customer, The TXN for ID No. " . $TID . " is Accepted, " . $company_data['sms_text'] . 'Thanks.';

$url = 'http://bulksms.mysmsmantra.com:8080/WebSMS/SMSAPI.jsp';

$fields = array(

'username' => 'xxxxxxx',

'password' => 'xxxxxxxx',

'sendername' => 'XXXXXX',

'mobileno' => $number,

'message' => $text

);

foreach($fields as $key => $value) {

$fields_string.= $key . '=' . $value . '&';

}
rtrim($fields_string, '&');

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_POST, count($fields));

curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);

$result = curl_exec($ch);

curl_close($ch);

?>
Team Leader Answered on November 12, 2018.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.