I am trying to develop a PHP based application to send sms across India to contacts picked from the database. After searching for hours, I found the following working (I tested it) script which makes use of fullonsms.com
as sms gateway but it sends a single message at a time and then loads the homepage.
But I don't know a lot about curl.
So
- I need help to understand what is actually being done.
- Secondly,how can I modify it to optimally send sms to multiple people(like will it be optimal to put it in a loop) without wasting data or unnecessary page loads.
3.After sending each SMS ,it loads homepage.So won't it try to load the homepage before sending SMS.If yes,can I remove the starred(** **) line to prevent this.
Here is my code:
<?php
$cookie_file_path = "/cookie.txt";
$username="username";
$password="password";
$tomobno="1234567890";
$message=urlencode("Hi buddy");
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://sms.fullonsms.com/login.php");
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_fie_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, "MobileNoLogin=$username&LoginPassword=$password&x=16&y=14");
$html=curl_exec($ch);
**curl_setopt($ch, CURLOPT_URL,"http://sms.fullonsms.com/home.php");**
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_fie_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POSTFIELDS, "ActionScript=%2Fhome.php&CancelScript=%2Fhome.php&HtmlTemplate=%2Fvar%2Fwww%2Fhtml%2Ffullonsms%2FStaticSpamWarning.html&MessageLength=140&MobileNos=$tomobno&Message=$message&Gender=0&FriendName=Your+Friend+Name&ETemplatesId=&TabValue=contacts");
$html = curl_exec($ch);
echo $html;
?>
There's is a similar question asked but answer accepted is off the topic and it uses a different gateway SMS sending through free gateway