I want to extract data from this URL with Php Curl
But i got an empty page.
I check to that link and inspect with mozilla network->xhr and there is an content in response tab.
How I can extract the data from that link with php curl?
Here is my code
$url = 'https://www.tiket.com/ajax/pingFlightSearch?d=CGK&a=DPS&date=2017-08-18&adult=1&child=0&infant=0&airlines=%5B%22LION%22%5D&subsidy=true&page_view=roundseperate';
$cURL = curl_init();
curl_setopt($cURL, CURLOPT_URL, $url);
curl_setopt($cURL, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17');
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($cURL, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($cURL, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($cURL, CURLOPT_AUTOREFERER, true);
curl_setopt($cURL, CURLINFO_HEADER_OUT, true);
curl_setopt($cURL, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($cURL, CURLOPT_VERBOSE,true);
curl_setopt($cURL, CURLOPT_HTTPHEADER, array(
"Host" => "www.tiket.com",
"User-Agent" => "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0",
"Accept" => "application/json, text/javascript, */*; q=0.01",
"Accept-Language" => "en-us,en;q=0.5",
"Accept-Encoding" => "gzip, deflate, br",
"Content-Type" => "application/cap+xml;charset=utf-8",
"X-NewRelic-ID" => "UQIGUlJXGwACUFZaAAM=",
"X-Requested-With" => "XMLHttpRequest",
"Connection" => "keep-alive",
"Pragma" => "no-cache",
"Cache-Control" => "no-cache"
));
$result = curl_exec($cURL);
print_r($result);
curl_close($cURL);
I must add 'X-Requested-With: XMLHttpRequest' at header of that link then response will come out.
Then the response will come out [response result][2]
/ajax/at the start of the path suggests that it might require a session to already exist.