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