When I debug a site via Chrome browser I get JSON response. But when I try to do this via PHP I get an error message.
failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found
Thanks for any help.
For example:
Things to do in Chrome:
Go to page: http://gruper.pl/warszawa and on the bottom you will see a button "Wiecej ofert". After click you will see in a debug:
http://gruper.pl/DataProvider.php?cityId=51&categoryId=0&mainNaviId=1&showBTile=true&page=1
and response:
[{"ID_PAGE":"59199","ID_CITY":"3952","main_city":"3952","date_start":"2014-02-23 18:00:00","date_end":"2014-03-01 23:59:00","price".....
Is there any possibility to get the same in PHP?
My code is:
<?php
$url = 'http://gruper.pl/DataProvider.php?cityId=51&categoryId=0&mainNaviId=1&showBTile=true&page=1';
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded
" .
"Accept:application/json
" .
"Accept-Encoding:gzip,deflate,sdch
" .
"X-Requested-With:XMLHttpRequest
",
'method' => 'GET'
),
);
$context = stream_context_create($options);
$result = (file_get_contents($url, false, $context));
?>
<html>
<head>
<meta charset="UTF-8">
</head>
</html>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…