Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用PHP从文件获取响应_Php_Wordpress_File Get Contents - Fatal编程技术网

无法使用PHP从文件获取响应

无法使用PHP从文件获取响应,php,wordpress,file-get-contents,Php,Wordpress,File Get Contents,大师 我正在尝试使用austpost.com.au网站获取跟踪详细信息,我已经为其编写了以下代码,但是,它似乎没有获取任何信息 $austpost_url = 'https://digitalapi.auspost.com.au/shipmentsgatewayapi/watchlist/shipments/99702032243801004670904'; $options = array( 'method' => 'get', 'contentTyp

大师

我正在尝试使用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;
直接跟踪链接:

我在Chrome的网络标签上找到了这一点,并找出了哪个请求正在加载跟踪详细信息。基本上,我只是在获得装运的状态之后。快照如下:


在这方面的任何帮助都将不胜感激,因为我正在使用PHP驱动我的代码,我想根据装运状态(我可以处理)更新WordPress posts状态。然而,在我继续之前,我一直停留在如何获取装运状态的问题上。

这是因为你需要一个有效的recaptcha令牌和证明你不是机器人的证据。不会像你想的那么简单。最简单但付费的方法是使用一些验证码解决公司,如(不是该答案的赞助商)及其
PHP
libs


如果您想使用他们的api,您需要通过基本身份验证使用用户名和密码进行身份验证。这里有更多详细信息:

首先检查fopen是否打开,添加phpinfo();在主文件中编码并选中此项


否则,请使用Curl函数而不是file_get_contents()

谢谢。我已经知道他们的API,但我没有他们的eParcel帐户,因此我无法访问它,因为他们拒绝了我的请求。如果我们每年有2000多个包裹,他们才有eParcel帐户。谢谢。我会的。我以前没有使用过Curl函数,你能告诉我如何传递这些参数吗?谢谢