What is the problem with the following code?
<?php
function file_get_contents_curl($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$var = file_get_contents_curl("http://www.sahibinden.com/131521670");
var_dump($var);
?>
It just display bool(false)
URL could be problem when put http://www.sahibinden.com/131521670 on browsers address bar, browser redirected to another page that I want its content.
when I add following lines
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_STDERR, $fp );
output was
* About to connect() to www.sahibinden.com port 80 (#0)
* Trying 195.33.232.72... * connected
* Connected to www.sahibinden.com (195.33.232.72) port 80 (#0)
> GET /131521670 HTTP/1.1
Host: www.sahibinden.com
Accept: */*
* Closing connection #0
* Failure when receiving data from the peer
CURLOPT_HEADER, 1); also produce same result.