How to show website and get content using PHP cURL? -
i need show website , content. purpose, tried php curl , run in localhost result not getting. currently, result getting bool(false)
.
index.php
$url = "https://www.test-data.de/test/data?_ts=4664397-1478603498594&command=start"; //use curl html content function geturlcontent($url){ $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_cookiefile, '/cookies.txt'); curl_setopt($ch, curlopt_cookiejar, '/cookies.txt'); curl_setopt($ch, curlopt_useragent, 'mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; .net clr 1.1.4322)'); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_header, 1); curl_setopt($ch, curlopt_followlocation, 1); $data = curl_exec($ch); $httpcode = curl_getinfo($ch, curlinfo_http_code); curl_close($ch); return ($httpcode>=200 && $httpcode<300) ? $data : false; } $results = geturlcontent($url); var_dump($results);
Comments
Post a Comment