SMS API - Send SMS to many numbers at a time - AARON SMITH TECH

Latest

Programming PHP tutorials for beginners. Technology and product reviews. Aaron Smith video tutorials for beginners.

sponsor

Wednesday, May 3, 2017

SMS API - Send SMS to many numbers at a time

bulk sms

Send SMS to many numbers at a time

For Bulk sms (sms sending to many numbers at a time), better to use SMS API with http connection. In this example you will see how to use SMS API with PHP script for Bulk sms sending.
For bulk sms sending with PHP you can use curl. Just send php array or JSON data to SMS API link. How to prepare this array data?

If you try to insert all numbers to 'to' => "+125352352,+32324234,+234234" Nothing happens:
https://www.proovl.com/api/send.php?user=******&token=******&from=********&to=125352352,32324234,234234&text=hi

It's working only with 1 number:
https://www.proovl.com/api/send.php?user=******&token=******&from=********&to=125352352&text=hi
WRONG sample:


$postfields = array(
'user' => "user",
'token' => "token",
'to' => "+125352352,+32324234,+234234", // WRONG, Nothing happens
'text' => "$text $created"
);

Bulk SMS with API php

How to send BULK sms to many numbers at a time?
You can use foreach php function.


$to = array("4444139833", "+4444255324", "+4444366244" );

foreach ($to as $to_x => $to_y){

$text = "Hello $to_x";

$postfields = array(
'user' => "user",
'token' => "token",
'to' => "$to_y",
'text' => "$text"
);
print_r($postfields);
}


You will see this:


personalized bulk sms sending

If you want make personalized bulk sms sending. You can include names to each sms.



$to = array("Andy" => "4444139833", "Jhon" => "4444255324", "Mike" => "4444366244" );

foreach ($to as $to_x => $to_y){

$text = "Hello $to_x!";

$postfields = array(
'user' => "user",
'token' => "token",
'to' => "$to_y",
'text' => "$text"
);

print_r($postfields);
}
sms api

bulk sms

Done. Now you can send ARRAY data to SMS API link with CURL request.

Bulk SMS php SCRIPT with curl request


$user = "*****"; // SMS API USER ID
$token = "*******"; // SMS API TOKEN
$from = "******"; // SMS API number (sender ID)

$to = array("Andy" => "4444139833", "Jhon" => "4444255324", "Mike" => "4444366244" );

foreach ($to as $to_x => $to_y){

$url = "https://www.proovl.com/api/send.php";

$text = "Hello $to_x!";

$postfields = array(
'user' => "user",
'token' => "token",
'from' => "$from",
'to' => "$to_y",
'text' => "$text"
);

if (!$curld = curl_init()) {
exit;
}

curl_setopt($curld, CURLOPT_POST, true);
curl_setopt($curld, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($curld, CURLOPT_URL,$url);
curl_setopt($curld, CURLOPT_RETURNTRANSFER, true);

$output = curl_exec($curld);

curl_close ($curld);

print_r($postfields);
}


bulk sms

You can use Bulk SMS with form for easy usage: https://sourceforge.net/projects/bulk-sms-script/


https://www.facebook.com/chakabiz
https://www.youtube.com/channel/UCYuMRNb_SRZ4FMsZjnHRZUA

No comments:

Post a Comment