curl - Sending free sms using PHP -
i trying develop php based application send sms across india contacts picked database. after searching hours, found following working (i tested it) script makes use of fullonsms.com
sms gateway sends single message @ time , loads homepage. don't know lot curl.
so
- i need understand being done.
- secondly,how can modify optimally send sms multiple people(like optimal put in loop) without wasting data or unnecessary page loads. 3.after sending each sms ,it loads homepage.so won't try load homepage before sending sms.if yes,can remove starred(** **) line prevent this.
here 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 similar question asked answer accepted off topic , uses different gateway sms sending through free gateway
1) need understand being done.
the code sending 2 http requests service. first request signs in username , password, , stores session cookies next request. second request 1 triggers send, takes mobile number , other details post data. second request able use session created first request because of cookiejar.
2) secondly,how can modify optimally send sms multiple people
if service allows input multiple mobile numbers (for example comma separated) optimal because require 2 requests send mobile numbers.
if not, have loop second request there 1 request per mobile number. remember change hardcoded post data uses next mobile number , name, instead of sending same number each time.
i suggest pausing period of time after each iteration of loop prevent sending requests fast. can use sleep(1)
example wait 1 second.
Comments
Post a Comment