开发者

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_POS开发者_JS百科TFIELDS, $jsonpost);

$response = curl_exec($ch);

curl_close($ch);


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


the easiest way to get that done would be to put your json into a hidden input-field and then have the containing form being submitted using POST.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜