2016-06-07 89 views
0

希望有人可以騰出時間來幫助菜鳥。我必須設置我的服務器,然後爲供應商提供必須能夠接收HTTP-Post請求的頁面的URL - 對於收到的每個帖子,您的頁面必須以「+ OK 「,以確認通知的正確傳送。用於HTTP POST請求的PHP腳本

POST /yourpage.php HTTP/1.1 
    Host: www.yoursite.com 
    Content-Length: 215 
    Connection: Keep-Alive 
    Content-type: application/x-www-form-urlencoded 
    Accept-Language: it 
    Cache-Control: no-cache 

destination=%2B40757732753&text=sms+test+example&originator=%2B391234567890&date_time=20160606074445 

什麼是最好的方法去這條指令?我有一些PHP的基本知識(仍然在學習),所以我們可以使用PHP。提前 Marinda

回答

0

您需要了解PHP中的全局變量
感謝,PHP已經$ _ POST能夠得到sended在後的主體內容,並用它做什麼。

<?php 
// this will create a variable with data of destination sent 
$destination = $_POST['destination'] 

... 
// just print +OK 
echo "+OK" 

但是如果你想發送短信到手機,你需要使用勞務派遣你,一般有這一點,並能夠發送短信的數量有限,取決於你的計劃成本。

我希望它能幫到你

0

檢查$ _POST變量。這是這種語言的一種特殊變量。然後,您可以:

<?php 

    $isOK = true; 

    // Check if POST parameter destination is set and it is not blank, you 
    // can repeat this validation with all your parameters, changing 
    // destination by its name. 
    if (!isset($_POST['destination']) || trim($_POST['destination']) == '') { 
     $isOK = false; 
    } 

    if ($isOK) { 
     echo "+OK"; 
    }