我正试图每天在Paticulr时间发送自动消息。使用SMS API。这包括一些将从mysql数据库中获取的信息。 当我尝试在mu本地服务器上对其进行测试时,它没有显示任何响应。
这是我的代码:
<?php
require_once("dbcontroller.php");
$db_handle = new DBController();
$query ="SELECT * FROM tbl_company where id=1";
$results = $db_handle->runQuery($query);
$c1=$results[0]['mobile1'];
$c2=$results[0]['mobile2'];
$date=date("d/m/Y");
// api key and date
$q="Select * from tbl_transaction where date='$date'";
$qr=mysqli_query($mysql,$q) or die($q.mysqli_error($mysql));
while($r=mysqli_fetch_object($qr))
{
$credit=$r->credit;
}
$key="xxxxxxxxxxxxxxxxxxxxxxx";
$senderId="TEST";
$date=date("d/m/Y");
$message = urlencode("Hello,Tjis is a test messgae,Credit bl: $credit)");
$curl = curl_init();
curl_setopt_array($curl,array(
CURLOPT_URL => "http://mysms.mydomain.com/rest/services/sendSMS/sendGroupSms?AUTH_KEY=$key&message=$message&senderId=$senderId&routeId=1&mobileNos=911111111&smsContentType=english&scheduleddate=10/11/2019 16:10",CURLOPT_RETURNTRANSFER => true,CURLOPT_ENCODING => "",CURLOPT_MAXREDIRS => 10,CURLOPT_TIMEOUT => 30,CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,CURLOPT_CUSTOMREQUEST => "GET",CURLOPT_HTTPHEADER => array(
"Cache-Control: no-cache"
),));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
在这里,当我尝试在本地服务器上的浏览器中运行php文件时,它将显示空白页面。但是当我直接在浏览器中使用url时,它就起作用了。