Press "Enter" to skip to content

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

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

You May Missed it !

Utmost Ideas to Keep Up the Spirit of Christmas 2020 15 Utmost Ideas to Keep Up the Spirit of Christmas 2020 - There are many things that you can do at Christmas…
Ecommerce Shop of diwali 2020 gifts Diwali 2020, The Bright Season of Indian E-commerce - Deepavali 2020 Indian Festive Season, the most joyful days in…
Why is Commitment Important for Success Why is Commitment Important for Success - Significance of Commitment in Life : The term commitment summons…
Karan Johar Again Gets Trolled Ruthlessly On Twitter For His Recent Tweet Karan Johar Again Gets Trolled Ruthlessly On Twitter For His Recent Tweet - In wake of the nepotism banter, producer Karan Johar has…
Spending Habits of the World’s Richest People Spending Habits of the World’s Richest People - Rich people are known for their good and bad reasons.…
Stream2watch #1 Stream2watch – Live Sport and Streams Online Free - Free online streaming website Stream2watch TV for watching all kind of sports,…
Find A Lawyer: Things You Need To Consider Before Hiring One Find A Lawyer: Things You Need To Consider Before Hiring One - Finding a lawyer is challenging. The matter in which you…
4 Things You Need To Know About Class Action Lawsuits - Getting injured as a result of someone else’s negligent behavior…
Scroll Up