PHP Curl with --data flag?

后端 未结 2 1416
忘了有多久
忘了有多久 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! ;-)

    0 讨论(0)
  • 2020-12-19 04:30

    example in:

    http://code.google.com/apis/gdata/articles/using_cURL.html

    curl https://www.google.com/accounts/ClientLogin \
    --data-urlencode Email=brad.gushue@example.com --data-urlencode Passwd=new+foundland \
    -d accountType=GOOGLE \
    -d source=Google-cURL-Example \
    -d service=lh2
    
    0 讨论(0)
提交回复
热议问题