【发布时间】:2020-09-07 11:54:06
【问题描述】:
大师,
我正在尝试使用我编写了以下代码的 austpost.com.au 网站获取跟踪详细信息,但是它似乎没有获取任何内容。
$austpost_url = 'https://digitalapi.auspost.com.au/shipmentsgatewayapi/watchlist/shipments/99702032243801004670904';
$options = array(
'method' => 'get',
'contentType' => 'application/json',
'muteHttpExceptions' => true,
'headers' => array ('Accept' => 'application/json, text/plain, */*',
'Accept-Encoding' => 'gzip, deflate, br',
'AP_CHANNEL_NAME' => 'WEB_DETAIL',
'api-key' => 'd11f9456-11c3-456d-9f6d-f7449cb9af8e',
'Connection' => 'keep-alive',
'Origin' => 'https://auspost.com.au',
'Referer' => 'https://auspost.com.au/mypost/track/'),
);
$context = stream_context_create($options);
$html = file_get_contents($austpost_url, false, $context);
echo $html;
直接追踪链接:https://auspost.com.au/mypost/track/#/details/99702032243801004670904
我通过转到 Chrome 中的 NETWORK 选项卡发现了这一点,并找出了哪个请求正在加载跟踪详细信息。基本上我只是在获得发货状态之后。截图如下:
在这方面的任何帮助都将不胜感激,因为我正在使用 PHP 来驱动我的代码,我想根据发货状态(我可以处理)更新 WordPress 帖子状态,但是,我无法获得这个在我继续之前的发货状态。
【问题讨论】:
标签: php wordpress file-get-contents