Skip to main content

How to send sms in php?

  Send sms in php



function sendsms(){

// Account details

$apiKey = urlencode('here you will paste your api');

// Message details

//$numbers = array(918123456789, 918987654321);

$numbers = 1234567890;

$sender = urlencode('TXTLCL');

$message = rawurlencode('This is your message');

 

//$numbers = implode(',', $numbers);

 

// Prepare data for POST request

$data = array('apikey' => $apiKey, 'numbers' => $numbers, "sender" => $sender, "message" => $message);

 

// Send the POST request with cURL

$ch = curl_init('https://api.textlocal.in/send/');

curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);

// Process your response here

echo $response;

}

sendsms();

Comments

Popular posts from this blog

How to check date format in PHP?

Check date format in PHP function isCorrectDateFromat($date){     if(!empty($date)){         $dateString = $date; // Replace this with your date string         $format = "Y-m-d"; // Replace this with your expected date format         $dateTime = DateTime::createFromFormat($format, $dateString);         if ($dateTime === false) { /*             echo "The date is not in the correct format."; */         } else {             $errors = DateTime::getLastErrors();             if (empty($errors)) { /*                 echo "The date is in the correct format."; */                 return true;             } else { /*                 echo "...