How to use PHP CURL to bypass cross domain

前端 未结 2 1932
长发绾君心
长发绾君心 2021-01-15 10:54

I need PHP to submit paramaters from one domain to another. JavaScript is not an option for my situation. I\'m now trying to use CURL with PHP, but have not been successful

相关标签:
2条回答
  • 2021-01-15 11:17

    Using false in CURLOPT_RETURNTRANSFER doesn't return anything by curl. make it true(or 1)

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    0 讨论(0)
  • 2021-01-15 11:23

    Well, its bit late. But adding this answer for further readers who might face similar issue. This issue arises some times when we are sending php curl request from a domain hosted over http to a domain hosted over https (http over ssl).

    Just add below code snippet before curl execution.

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $output = curl_exec($ch);
    
    0 讨论(0)
提交回复
热议问题