我试图使用澳大利亚后api。在第一步中,我试图重新接受已接受的国家/地区列表。我的代码如下。但在显示空白页面的回报中。当我尝试var_dump($ parcelTypesJSON)时,它显示为null。我的脚本链接是click here
<?php
// Set your API key: remember to change this to your live API key in production
$apiKey = '52a5527a-bf5a-4c31-9182-f91de2fe18ec';
$urlPrefix = 'digitalapi.auspost.com.au';
$parcelTypesURL = 'https://' . $urlPrefix . '/postage/country.json';
// Retrieve the list of country codes
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $parcelTypesURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('AUTH-KEY: ' . $apiKey));
$rawBody = curl_exec($ch);
// Check the response; if the body is empty then an error occurred
if(!$rawBody){
die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
}
// All good, lets parse the response into a JSON object
//var_dump($parcelTypesJSON);
$parcelTypesJSON = json_decode($rawBody);
?>