我想要收到错误代码.由短信主机服务器在php中实现


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

我想从SMS主机服务器接收错误Curl_error curl_errno curl_strerror所有这些函数返回错误,但不是我想要的方式,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);