PHP Curl with --data flag?

后端 未结 2 1423
忘了有多久
忘了有多久 2020-12-19 03:57

Can someone write a PHP script that reproduces the functionality of this linux shell command?

curl -X POST -u \"USERNAME:PASS\" \\
    -H \"Content-Type: ap         


        
2条回答
  •  误落风尘
    2020-12-19 04:14

    A general rule: use the "--libcurl example.c" option to get curl to generate source code for a C program that would use libcurl. The API is very similar to the PHP/CURL one as you will see and you should then quickly realize that --data translates to CURLOPT_POSTFIELDS.

    Oh, and you'll note that the -X usage is completely superfluous! ;-)

提交回复
热议问题