尝试连接到HMRC MTD增值税申报表。
$access_token = $_SESSION['access_token'];
$handle = curl_init();
$url = "https://test-api.service.hmrc.gov.uk/organisations/vat/643159930/returns";
$postData = array(
'Accept' => 'application/vnd.hmrc.1.0+json',
'Authorization' => 'Bearer '.$access_token,
'Content-Type' => 'application/json'
);
print_r($postData);
curl_setopt_array($handle,
array(
CURLOPT_URL => $url,
// Enable the post response.
CURLOPT_POST => true,
// The data to transfer with the response.
CURLOPT_POSTFIELDS => $postData,
CURLOPT_RETURNTRANSFER => true,
)
);
$data = curl_exec($handle);
curl_close($handle);
echo $data;
我收到回信:
Array([Accept] => application / vnd.hmrc.1.0 + json [Authorization] =>承载3f69148194dfd7dffddc237cc1388df [Content-Type] => application / json){“ code”:“ MISSING_CREDENTIALS”,“ message”: “未提供身份验证信息”}
知道为什么吗?