php curl_exec returns empty

前端 未结 4 925
刺人心
刺人心 2020-12-16 15:08
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, $url);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_PROXY, $proxy); // $proxy is ip of          


        
4条回答
  •  不思量自难忘°
    2020-12-16 15:48

    You're trying to access a HTTP response code before you actually make the HTTP call. Reverse the execution as follows:

    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch , CURLINFO_HTTP_CODE); // this results 0 every time
    

提交回复
热议问题