I am trying to get the page contents from the remote site. It is working for many sites. But some of the urls like http://www1.macys.com/ returns nothing. Can anyone please tell me the solution or what the problem is? Am I miss anything?
If I am using fopen() or file_get_contents() it shows the warning "Redirection limit reached, aborting"
Below is my code.
<?php
$url = 'http://www1.macys.com/shop/product/volcom-stripe-thermal-shirt?ID=1155481&CategoryID=30423#fn=sp%3D1%26spc%3D996%26ruleId%3D27%26slotId%3D1';
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; rv:19.0) Gecko/20100101 Firefox/19.0');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$contents = curl_exec($ch);
if(curl_errno($ch)) {
echo 'Error: ' . curl_error($ch) . '<br><br>';
}
echo 'Contents: '; print_r($contents); echo '<br><br>';
curl_close($ch);
?>