如何通过cURL解析AJAX?

时间:2017-06-05 04:03:00

标签: php ajax curl

我正在尝试解析这个网址:

https://halykbank.kz/presscenter/novosti

新闻由AJAX加载。在网络中我找到了URL,它必须显示已加载的新闻,但只有

{"result":false,"hint":"NO_AUTHORIZATION_DATA"}

为什么我会这样?这里的URL,我认为必须向我显示加载的新闻:

https://backend.halykbank.kz/struct/category-items?categoryId=199&sort=position%20desc&offset=200&limit=100

2 个答案:

答案 0 :(得分:0)

您必须发送这些标题

Auth-User-Id, Auth-Token, Auth-Time

答案 1 :(得分:0)

composer require guzzlehttp/guzzle:~6.0


$client = new GuzzleHttp\Client();
$res = $client->get('https://api.github.com/user', ['auth' =>  ['user', 'pass']]);
echo $res->getStatusCode(); // 200
$json_string = $res->getBody();

$json_obj = json_decode($json_string); //return Object<BR>
$json_arr = json_decode($json_string,true); //return Array