2016-06-07 140 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"; 
    }