bob_the _builder Posted May 14, 2007 Share Posted May 14, 2007 Hi, Is the following a reasonable way to loop through database and send out sms, or are there better ways to go about it? $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 Link to comment https://forums.phpfreaks.com/topic/51279-sms/ Share on other sites More sharing options...
bob_the _builder Posted May 14, 2007 Author Share Posted May 14, 2007 $user = '###'; $password = '###'; $api_id = '###'; $baseurl ='http://api.clickatell.com'; $text = urlencode('This is an example message'); $url = "$baseurl/http/auth?user=$user&password=$password&api_id=$api_id"; $ret = file($url); $sess = split(":",$ret[0]); $sess_id = trim($sess[1]); if ($sess[0] == "OK") { $sql = mysql_query("SELECT * FROM calendar WHERE sendtxt = 1"); while ($row = mysql_fetch_array($sql)){ $text = urlencode('Hi '.$row['firstname'].' message here'); $url = "$baseurl/http/sendmsg?session_id=$sess_id&to=".$row['cellphone']."&text=$text"; $ret = file($url); } if (!$ret) echo 'send message failed'; else echo 'success'; }else{ echo 'Authentication failure'; } Link to comment https://forums.phpfreaks.com/topic/51279-sms/#findComment-252629 Share on other sites More sharing options...
neel_basu Posted May 14, 2007 Share Posted May 14, 2007 Do you have any problem with it ?? Link to comment https://forums.phpfreaks.com/topic/51279-sms/#findComment-252648 Share on other sites More sharing options...
bob_the _builder Posted May 14, 2007 Author Share Posted May 14, 2007 Hi, Na seems to work fine. I have never used sms before, was just wanting to be sure it is a plausible way to go about it. Thanks Link to comment https://forums.phpfreaks.com/topic/51279-sms/#findComment-253035 Share on other sites More sharing options...
textbox Posted May 14, 2007 Share Posted May 14, 2007 Hello Bob, i used Clickatell briefly but couldnt stand it after a while. itagg.com is a lot easier to use, with great support and great documentation. I am using it extensively in my final major project for university and have successfully got MMS messages inserting into a db, SMS messages from phone to internet and internet to phone and WAP push working all from the documentation and a little bit of php knowledge. Itagg is capable of things like location based texts, wap push, downloads, java games, voting, competitions and mailing lists! Link to comment https://forums.phpfreaks.com/topic/51279-sms/#findComment-253042 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.