How to Send SMS using PHP Program (full code sample included)

Date:

Are you looking how to send message to mobile using php code? Are you searching for how to send sms using php source code?

How to send sms with php code from localhost

<?php

//Your authentication key
$authKey = "YourAuthKey";

//Multiple mobiles numbers separated by comma
$mobileNumber = "9999999";

//Sender ID,While using route4 sender id should be 6 characters long.
$senderId = "102234";

//Your message to send, Add URL encoding here.
$message = urlencode("Test message");

//Define route 
$route = "default";
//Prepare you post parameters
$postData = array(
    'authkey' => $authKey,
    'mobiles' => $mobileNumber,
    'message' => $message,
    'sender' => $senderId,
    'route' => $route
);

//API URL
$url="http://api.msg91.com/api/sendhttp.php";

// init the resource
$ch = curl_init();
curl_setopt_array($ch, array(
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => $postData
    //,CURLOPT_FOLLOWLOCATION => true
));


//Ignore SSL certificate verification
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);


//get response
$output = curl_exec($ch);

//Print error if any
if(curl_errno($ch))
{
    echo 'error:' . curl_error($ch);
}

curl_close($ch);

echo $output;
?>
0Shares
Erric Ravihttps://www.storifynews.com
Erric Ravi is an entrepreneur, speaker & the founder of Storify News and Gurgaon Times of India He is the Co-Founder of The Storify News Times. Forbes calls him a top influencer of Chief Marketing Officers and the world’s top social marketing talent. Entrepreneur lists him among 50 online marketing influencers to watch. Inc.com has him on the list of 20 digital marketing experts to follow on Twitter. Oanalytica named him #1 Global Content Marketing Influencer. BizHUMM ranks him as the world’s #1 business blogger.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Share post:

Subscribe

New York
broken clouds
1.4 ° C
2.4 °
-0 °
52 %
4kmh
75 %
Tue
1 °
Wed
6 °
Thu
6 °
Fri
-5 °
Sat
-2 °

Popular

More like this
Related

3 Simple Marketing Techniques That Will Help Expand Your Business

When it comes to growing your business, good marketing...

Problem Solving Assessment – Everything You Need To Know

Challenges arise in every firm, and recruiters must employ...

5 Fantastic Ways Being Sustainable Helps Your Business

For businesses, sustainability is more than just a fad...

HOTP vs TOTP: Differences and advantages

Digitalization has truly made life much easier; you can...