Foreword
Today, a few days ago to be precise, I was connecting to the interfaces of other departments, so I adjusted the curl function encapsulated by previous people. The strange thing is that curl -d "parms" url on the command line can be successful when making requests using post. Could it be that the "ancestral" curl function is used incorrectly? ?
Text
Troubleshooting of the cause
Because the command line works, but calling the function does not, it is very strange.
Possible reasons:
1. The parameters or url are wrong, there is a missing s or something like that--after correcting it, it will be eliminated
2. Is there something wrong with the encapsulated curl function? -------Thinking about calling it from so many places, there should be no problem, but in the end I still felt that there was something wrong with this function. Suddenly I saw one of the markers that urlencoded the parameters. I thought I would give it a try. Damn it, it actually works. Yes, it really is here.
Let’s talk about the principle
After checking the PHP manual, I found: When configuring the parameters of CURLOPT_POSTFIELDS, although this parameter says that both array and urlencoded parameters can be passed, there is still a difference: if value is an array, Content- The Type header will be set to multipart/form-data. This is it. As a result, the interface provider cannot receive parameters consistently.
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });The above introduces the curl of PHP in the Pitfall series, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.