检查textlocal上已发送短信的状态

时间:2013-11-22 08:26:07

标签: php

我使用text local(textlocal.com)使用PHP发送短信,这是我必须发送短信的代码:

// Send the POST request with cURL
$ch = curl_init('https://www.txtlocal.com/sendsmspost.php'); //note https for SSL
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch); //This is the result from Textlocal
curl_close($ch);

我该如何检查它是否失败?

1 个答案:

答案 0 :(得分:0)

尝试

$resultStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($resultStatus != 200) {
        die('Request failed: HTTP status code: ' . $resultStatus);
    }

 var_dump($result );

参考Manual