Page 1 of 1

sending batch sms - ex: clickatell

Posted: Wed Jun 18, 2008 1:28 am
by phpnewbie112
Hello, I am using a gateway similar to clickatell, I am using a simple code where I can send an sms successfuly with good error results. I have a small question, the gateway allow bulk sms by simply adding comma seperated numbers for ex. 123456,789780,123987
with the given code I am using, when I input the 2nd number it is not working, could you pls advice how can I loop it in a way to send the sms to each number while giving failure error for any failed number.

sms.html

Code: Select all

 
<form method="POST" action="sms.php">
   <table border="0" width="100%" id="table1">
      <tr>
         <td width="67">From:</td>
 
         <td><select size="1" name="from">
         <option value="Sender1">Sender1</option>
         <option value="Sender2">Sender2</option>
         </select>
         </td>
      </tr>
      <tr>
         <td width="67">To:</td>
 
         <td><input type="text" name="to" size="20"> </td>
      </tr>
      <tr>
         <td width="67">&nbsp;</td>
         <td>&nbsp;</td>
      </tr>
      <tr>
         <td width="67">&nbsp;</td>
 
         <td>&nbsp;</td>
      </tr>
      <tr>
         <td colspan="2"><textarea rows="6" name="text" cols="31"></textarea></td>
      </tr>
   </table>
   <table border="0" width="100%" id="table2">
      <tr>
 
         <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
         <td width="67">&nbsp;</td>
         <td>&nbsp;</td>
      </tr>
   </table>
      <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
 
____________________________

send.php

Code: Select all

 
<?
@import_request_variables("gpc");
 
 
$user = "x";
$password = "y";
 
 
$baseurl ="http://siteurl";
$url = "$baseurl/clientsapi.php?username=$user&password=$password&action=sendsms&from=$from&to=$to&text=$text";
 
 
 if ( (!empty($from)) && (!empty($to)) && (!empty($text)) )
 {
$ret = file($url);
$send = split(":",$ret[0]);
 
//echo $send[1];
if ($send[0] == "OK")  {
echo "Success: ". $send[1];
 
}
else {
echo "Failure: ". $send[1];
 
}
exit();
}
?>