0

i am trying to get web page content with curl from some websites but they return 400 bad request ( file_get_contents return empty ) here's the function i am using :

function file_get_contents_curl($url) {
    $ch = curl_init(); 

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');

    $data = curl_exec($ch);
    curl_close($ch);

    return $data;
}
Gam eek
  • 3
  • 4

1 Answers1

0

Put error_reporting(E_ALL); line at the top file where you are calling this function.

It will generate the cause of an error.

Gufran Hasan
  • 8,910
  • 7
  • 38
  • 51