我想通过PHP和curl发送短信。但是它的回应是
“状态:400”,无效编号,数据:空”。
请检查我的代码我在做什么错。这是我的代码。
$number='*****';
$toPost = array(
"Authkey"=>"******",
"Mask"=>'*****',
"user" => $username,
"pass" => $password,
"to" => $number,
"sender" => urlencode($from),
"text" => urlencode($message),
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://buy.techsolsms.com/api/v1/quicksms.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $toPost);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // If you use this line, you will get response from API in $result below.
$result = curl_exec($ch);
echo "<span class='alert alert-success'> '$result'</span>" ;
echo "<script>alert('$result')</script>";
curl_close($ch);
答案 0 :(得分:0)
状态400-HTTP代码,错误的请求(无效的数字)
检查API文档,可能是您发送的电话号码格式无效。