when I copy and paste the following url in the address bar, it opens the page correctly:
https://www.lacourt.org/casesummary/ui/casesummary.aspx?CaseNumber=BC510457
but the following code returns a case not found message from the site when I run it on localhost:
<?php
$url = 'https://www.lacourt.org/casesummary/ui/casesummary.aspx?CaseNumber=BC510457';
echo file_get_contents($url);
?>
Why is file_get_contents not returning the same page as when I type the url directly in the address bar? Any suggestions?
Thank you.
first, i can't connect the url, but you can try set user-agent
in request header. like this :)
`
$url = 'https://www.lacourt.org/casesummary/ui/casesummary.aspx?CaseNumber=BC510457';
$header = [
'header'=>[
'method'=>'GET',
'header'=>['user-agent'=>'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36']
]
];
$ctx = stream_context_create($header);
echo file_get_contents($url,false,$ctx);
`