curl command line to PHP curl

浪尽此生 提交于 2019-12-24 01:40:12

问题


How do I translate this commandline PayPal cURL request --insecure

curl -s --insecure 
-H "X-PAYPAL-SECURITY-USERID: api_username" 
-H "X-PAYPAL-SECURITY-PASSWORD: api_password" 
-H "X-PAYPAL-SECURITY-SIGNATURE: api_signature" 
-H "X-PAYPAL-REQUEST-DATA-FORMAT: NV" 
-H "X-PAYPAL-RESPONSE-DATA-FORMAT: NV" 
-H "X-PAYPAL-APPLICATION-ID: app_id"

I know I will place -H values to:

curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-PAYPAL-SECURITY-USERID: api_username', 'X-PAYPAL-SECURITY-PASSWORD: api_password'));

But I am not sure with the --insecure.


回答1:


From http://curl.haxx.se/docs/manpage.html :

-k, --insecure: (SSL) This option explicitly allows curl to perform "insecure" SSL connections and transfers. All SSL connections are attempted to be made secure by using the CA certificate bundle installed by default. This makes all connections considered "insecure" fail unless -k, --insecure is used.

Looking further at reading SSL page with CURL (php), this tells you that you have to set CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST to FALSE. This basically overrides the "security checks".

I think that's what you need to mirror the --insecure command line option.



来源:https://stackoverflow.com/questions/16207236/curl-command-line-to-php-curl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!