duanbei2914 2018-09-05 10:58
浏览 38

如何检查方法中的请求?

My test.php code are bellow:

<?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>

When I click the Click Me button, in the browser I only get the post action, which is the request PHP file itself.

My requirement is I want to check the get_data's request. How can I test it?

Because when I click the <kbd>Click</kbd> button I get bellow error, but in the browser I can not to check the get_data's request detail(http://demo:8000/api/users/register/):

{
    "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":{

    }
}

So the request in the method we can not check in browser, but how can I check it in other way?

enter image description here


EDIT-01

I mean, in my test.php, there are two requests, one is click the Click Me button, which send a post request to self php file. the other is execute the get_data() function, which is Requests' post. but in browser there only shows the previous one.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 数学建模,尽量用matlab回答,论文格式
    • ¥15 昨天挂载了一下u盘,然后拔了
    • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
    • ¥20 易康econgnition精度验证
    • ¥15 msix packaging tool打包问题
    • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能