我想收到错误代码。通过 php 中的短信主机服务器

I want to recive the error code. by the sms host server in php

我想从短信主机服务器接收错误信息 curl_error curl_errno curl_strerror 所有这些功能 returns 错误但不是我想要的方式,mysmshost 说你会收到这样的代码,202 表示错误的手机号码,301 表示错误身份验证,我想收到那些错误代码请帮助。 这是我的代码。

//sending message
        $authKey = "my_authentication_key";
        $senderId = "sender";
        $message = urlencode("Hello Its Working..");
        $route = "1";
        $campaign = 'Default';
    //Prepare you post parameters
$postData = array(
    'authkey' => $authKey,
    'mobiles' => $number,
    'message' => $message,
    'sender' => $senderId,
    'route' => $route,
    'campaign' => $campaign
);
//API URL
$url="http://sms.mysmshost.com/sendhttp.php";
// init the resource
$ch = curl_init();
curl_setopt_array($ch, array(
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => $postData
    //,CURLOPT_FOLLOWLOCATION => true
));
//Ignore SSL certificate verification
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
//get response
$output = curl_exec($ch);
//Print error if any
if(curl_errno($ch))
{
    echo curl_error($ch)."-curl_error<br/>";
    $chcode =curl_errno($ch); 
    echo $chcode;
    echo '<br/>error:' . curl_strerror($chcode)."<br/>";
}
curl_close($ch);
echo $output;

Curl_errorno() 没有执行,即使我在没有 if 条件的情况下打印它们也没有结果。

试试这个

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));

$server_output = curl_exec($ch);
curl_close($ch);

print_r($server_output);