-1
我使用Curl使用網關發送短信,一旦一切正常就獲得200,如果現在不發送,則獲得400,我應該從網關獲得其他信息,例如電話號碼和其他信息,所以我錯過了什麼?在PHP中的捲曲響應
// 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);
謝謝您最好的問候,
我不熟悉的捲曲度可言,但'curl_getinfo'是你確定你不想要'$ response'變量?你正在指定'$ handle'。因爲我認爲你會希望獲得有關回復的信息。可能是錯誤的。 – sircapsalot 2013-03-12 14:14:30
我不明白,我該怎麼辦? – test 2013-03-12 14:33:44
感謝您的按摩:)(抱歉) – kjetilh 2013-03-12 15:03:44