我正在尝试通过我在php中开发的系统发送短信我正在使用SMS API,但是当我发送请求时,它只给出了操作时间而没有别的...相同的代码与其他API一起使用它工作得很完美..当我在浏览器中使用URL时,它也能很好地工作 请帮忙
<?php
function SendSMS($userAccount,$passAccount,$numbers, $sender, $msg, $MsgID,$timeSend=0,$dateSend=0)
{
$applicationType="25";
$numbers = str_replace(" ","", $numbers);
$numbers = str_replace(",,",",", $numbers);
$sender = urlencode($sender);
$url="http://services.sau.edu.sa/sms/api/send.aspx?username=".$userAccount."&password=".$passAccount."&numbers=".$numbers."&language=en&text=".$msg."&smssender=mjales";
// Send the request
$output = file($url);
$result =explode(":", $output[0]);
return $result;
}
?>
答案 0 :(得分:0)
在使用之前使用来自ini设置的this.Enable Curl的CURL。
function SendSMS($userAccount,$passAccount,$numbers, $sender, $msg, $MsgID,$timeSend=0,$dateSend=0)
{
$applicationType="25";
$numbers = str_replace(" ","", $numbers);
$numbers = str_replace(",,",",", $numbers);
$sender = urlencode($sender);
/*$url="http://services.sau.edu.sa/sms/api/send.aspx?username=".$userAccount."&password=".$passAccount."&numbers=".$numbers."&language=en&text=".$msg."&smssender=mjales";
*/
$url="http://services.sau.edu.sa/sms/api/send.aspx";
$data1=array(
'username'=>$userAccount,
'password'=>$passAccount,
'numbers'=>$numbers,
'language'=>'en',
'text'=>$msg,
'smssender'=>mjales
);
// Send the request
//$output = file($url);
//$result =explode(":", $output[0]);
//return $result;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data1);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}