-1

Curlを使用してゲートウェイを使用してSMSを送信しています、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 に答える