Using ajax to make a curl request

前端 未结 3 368
逝去的感伤
逝去的感伤 2021-01-25 05:51

This answer has helped me largely but hasn\'t fully resolved my issues. I\'m using code similar to that, which is:

function getResponse() {

    var the_url = \"         


        
3条回答
  •  一整个雨季
    2021-01-25 06:41

    You need a page on your server that the JavaScript points at, which has the curl command in it. You can't just run cURL directly as a url like that.

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $the_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_REFERER, $_SERVER['REQUEST_URI']);
    $result = curl_exec($ch);
    curl_close($ch);
    echo $result;
    

提交回复
热议问题