简体   繁体   中英

How do I get all my 'content' from the Request Body in a POST request?

Well title says all I guess.

I've tried to print_r($_SERVER) but my 'post-request' I made with fiddler doesn't show up.

I'm really out of my mind after trying about 1 hour now :S

What I actually want is to send a POST request with JSON in the request-body. Then I want to json_decode(request-body); This way I can use the variables to reply. So I don't need to put my variables in the URL

Edit:

This is my POST

$url = 'http.........jsonAPI/jsonTestAPI.php';
$post = array("token" => "923874657382934857y32893475y43829ufhgjdkfn");
$jsonpost = json_encode($post);

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonpost);

$response = curl_exec($ch);

curl_close($ch);

Try file_get_contents('php://input'); or PHP global $HTTP_RAW_POST_DATA .

最简单的方法是将json放入隐藏的输入字段中,然后使用POST提交包含表单。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM