如何检查方法中的请求?

时间:2018-09-05 10:59:00

标签: php request

我的test.php代码如下:

<?php

// First, include Requests
include('../library/Requests.php');

// Next, make sure Requests can load internal classes
Requests::register_autoloader();

function get_data(){
    // Now let's make a request!

    $params = array(
        "ws_tblclients_id" => 1232,
        "email" => "test22@cd.com",
        "username" => "asdas_asda",
        "phone" => "1518233776",
        "password" => "123456"
    );

    $request = Requests::post('http://demo:8000/api/users/register/', $params, null);

    // Check what we received
    echo "<pre>";

    var_dump($request);
    echo "</pre>";
}



if(isset($_GET['submit_get_data']) ){
    get_data();
}


?>

<form action="" method="post">
    <button name="submit_get_data" value="submit_get_data" type="submit">Click Me</button>
</form>

当我单击“单击我”按钮时,在浏览器中我只会执行post操作,这是请求PHP文件本身。

我的要求是我要检查get_data的请求。我该如何测试?

因为当我单击 Click 按钮时出现以下错误,但是在浏览器中我无法检查get_data的请求详细信息(http://demo:8000/api/users/register/):< / p>

{
    "body":"{"password":["This field must be filled。"],"phone":["This field must be filled"],"username":["This field must be filled"]}",
    "raw":"HTTP/1.1 400 Bad Request
Content-Length: 118
X-Frame-Options: SAMEORIGIN
Allow: POST, OPTIONS
Vary: Accept, Cookie
Content-Type: application/json
Date: Wed, 05 Sep 2018 10:29:50 GMT
Connection: close

{"password":["This field must be filled"],"phone":["This field must 
be filled"],"username":["This field must be filled"]}",
    "headers":{

    },
    "status_code":400,
    "protocol_version":1.1,
    "success":false,
    "redirects":0,
    "url":"http://demo:8000/api/users/register/",
    "history":[

    ],
    "cookies":{

    }
}

所以我们无法在浏览器中检入方法中的请求,但是我该如何以其他方式检入?

enter image description here


EDIT-01

我的意思是,在我的test.php中,有两个请求,一个是单击“单击我”按钮,这会将一个发布请求发送到self php文件。另一个是执行get_data()函数,这是Requests的帖子。但在浏览器中仅显示前一个。

0 个答案:

没有答案