thinkphp - When writing api, when to use $_POST to receive post messages, and when to use php://input?
怪我咯
怪我咯 2017-07-07 10:34:43
0
1
1086

Now we need to write an api interface, using the post method. Other companies send json data to this api post
But here comes the problem. When I tested it myself, I used $_POST to receive the data at the beginning. When simulating sending, I used PHP's curl mode to post it, and everything was normal. Then when the other party called the api, it said it failed. When I saw it, the received data was empty. I used Fiddler to simulate the post request, and it also failed. It is indeed empty, $_POST cannot receive data, and then I use php://input to receive it successfully. However, I don’t know why, if I use php://input, my php uses curl to simulate the post, but it can’t be received! ! ! !
That is to say
curl post =>> $_POST
Other normal posts =>> php://input
What is this, I Baidu it

I don’t see why either

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all (1)
phpcn_u1582

Read more documentation

When the Content-Type of the HTTP POST request is application/x-www-form-urlencoded or multipart/form-data, the variables will be passed into the current script in the form of an associative array

http://php.net/manual/zh/rese...

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!