The mentioned link in variable $link is redirect to product page. Its working fine when i call/open it in browser. But it does not work in PHP file_get_contents function.
My Code:
$url = "750651";
$link = "http://www.costco.com/CatalogSearch?storeId=10301&catalogId=10701&langId=-1&keyword=$url";
$link = str_replace('&','&',$link);
$res = file_get_contents(html_entity_decode(urldecode($link)));
Error
Warning: file_get_contents(http://www.costco.com/CatalogSearch?storeId=10301&catalogId=10701&langId=-1&keyword=750651): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden
How can I prevent conversion of &
into &
in file_get_contents functions
I also have tried following code but no success
$link = "http://www.costco.com/CatalogSearch?";
$options = array("storeId"=>"10301","catalogId"=>"10701","langId"=>"-1","keyword"=>$url);
$link .= http_build_query($options,'','&');
$res = file_get_contents($link);