0
我想使用curl和PHP發送使用fullonsms.com SMS網關的短信。需要幫助來查找PHP和Curl代碼中的錯誤
下面是代碼: -
<?php
session_start();
mysql_connect('localhost','root','') or die('Error connecting to database');
mysql_select_db('SMSapp') or die('Database Selection Error');
$query='Select * from contacts';
$cookie_file_path = "/cookie.txt";
$username="*****";
$password="***";
$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_file_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);
if($query_run=mysql_query($query))
{
$row_count=mysql_num_rows($query_run);
if($row_count==0)
{
echo 'Zero rows received';
die();
}
else
{
for($i=0;$i<3;$i++)
{
curl_setopt($ch, CURLOPT_URL,"http://sms.fullonsms.com/home.php");
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_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);
$tomobno=mysql_result($query_run,$i,'mobno');
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");
curl_exec($ch);
sleep(1);
}
}
}
$html = curl_exec($ch);
echo $html;
?>
劇本是工作的罰款1個SMS但是當我加入了LOP和數據庫的事情來設置$tomobno
(手機號碼)動態地,它停止發送消息。 問題是: -
我在我的數據庫中有三個手機號碼,但我沒有收到任何短信。
(我已經回覆了數字,腳本選擇了所有這些。問題出在CURL代碼上。)我是CURL中的一個tyro。請幫助。
(請不要不必要downvote問題)
這裏是參考wrking API,如果它可以幫助你:https://github.com/kingster/FullonSMS-API/blob/master/fullonsms-api.php .. –
@Coderanonymous:謝謝爲響應。但問題是發送多個SMS.The上面的腳本工作正常1 sms,但當我修改它多個短信,它不會發送任何短信。 –
我不知道你做了哪些修改來完成這項工作,我建議的所有操作都是恢復代碼,一步步完成,並檢查它失敗的步驟。否則提及或突出顯示您正在更改的行。 –