PHP CURL & HTTPS

前端 未结 4 1294
深忆病人
深忆病人 2020-11-22 09:25

I found this function that does an AWESOME job (IMHO): http://nadeausoftware.com/articles/2007/06/php_tip_how_get_web_page_using_curl

/**
 * Get a web file (         


        
4条回答
  •  天涯浪人
    2020-11-22 09:59

    One important note, the solution mentioned above will not work on local host, you have to upload your code to server and then it will work. I was getting no error, than bad request, the problem was I was using localhost (test.dev,myproject.git). Both solution above work, the solution that uses SSL cert is recommended.

    1. Go to https://curl.haxx.se/docs/caextract.html, download the latest cacert.pem. Store is somewhere (not in public folder - but will work regardless)

    2. Use this code

    ".$result; //echo "
    Path:".$_SERVER['DOCUMENT_ROOT'] . "/ssl/cacert.pem"; // this is for troubleshooting only ?>
    1. Upload the code to live server and test.

提交回复
热议问题