SMS
Posted: Mon May 14, 2007 3:40 am
Hi,
Is the following a reasonable way to loop through database and send out sms, or are there better ways to go about it?
Thanks
Is the following a reasonable way to loop through database and send out sms, or are there better ways to go about it?
Code: Select all
$sql = mysql_query("SELECT * FROM calendar WHERE sendtxt = 1");
while ($row = mysql_fetch_array($sql)){
$user = '###';
$password = '###';
$api_id = '###';
$baseurl ="http://api.clickatell.com";
$text = urlencode("This is an example message");
$to = "".$row['cellphone']."";
$url = "$baseurl/http/auth?user=$user&password=$password&api_id=$api_id";
$ret = file($url);
$sess = split(":",$ret[0]);
if ($sess[0] == "OK") {
$sess_id = trim($sess[1]);
$url = "$baseurl/http/sendmsg?session_id=$sess_id&to=$to&text=$text";
$ret = file($url);
$send = split(":",$ret[0]);
if ($send[0] == "ID")
echo "success<br>message ID: ". $send[1];
else
echo "send message failed";
}else{
echo "Authentication failure: ". $ret[0];
}
}Thanks