-1

我正在使用 Curl 使用网关发送短信,a,当一切正常时收到 200,如果现在不发送,则收到 400,我应该从网关获取其他信息,例如电话号码和其他信息,所以我错过了什么吗?

// if the Form is submited 
//if (isset($_POST['PhoneNumber'])) {
if ($_SERVER['REQUEST_METHOD'] == "POST"){

// Fetch Phone Number and escape it for security 
$Phone = mysql_real_escape_string($_POST['PhoneNumber']);

// Fetch Text and escape it for security 
$Text = mysql_real_escape_string($_POST['Text']);

// Structure the URl
$url = "http://xxxxxxxxxxx:xxxx?PhoneNumber=".urlencode($Phone)."&Text=".urlencode($Text)."&User=xxx&Password=xxx";

// Handeling the Curl
$handle = curl_init($url);

curl_setopt($handle,  CURLOPT_RETURNTRANSFER, TRUE);

/* Get the HTML or whatever is linked in $url. */
$response = curl_exec($handle);

/* Check for 404 (file not found). */
$httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);

if ($httpCode=="200"){

  // if everything is okey , the gateway returns 200 which means OK
  echo "Massage Was Sent , Thank you ";



} elseif ($httpCode=="400"){
  // if there was an error , the form returns a 400 which means that the sms Failed 
  echo "Massage was not sent , Please Try Again";

}

// Cloase the Curl Connection
curl_close($handle);

谢谢您最好的问候,

4

1 回答 1

0

$response 应该包含响应,尝试: echo '<pre>'; print_r($response); echo '</pre>'; 显示其内容

于 2013-03-12T14:51:48.610 回答