我刚刚创建了一个Face API密钥并转到Microsoft的测试console来测试它,但是我得到了无效的密钥错误作为响应。我无法弄清楚如何将westus更改为westcentralus,因此我将一个小的PHP代码放在一起发送请求。同样的错误。这是代码:
$postData = array(
'url' => '...url to image..',
);
// Setup cURL
$ch = curl_init('https://westcentralus.api.cognitive.microsoft.com/face/v1.0/detect?returnFaceId=true&returnFaceLandmarks=false&returnFaceAttributes=age,gender');
curl_setopt_array($ch, array(
CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => array(
'Ocp-Apim-Subscription-Key' => '9******************************6',
'Content-Type: application/json'
),
CURLOPT_POSTFIELDS => json_encode($postData)
));
// Send the request
$response = curl_exec($ch);
答案 0 :(得分:0)
您应该更改以下代码行:
'Ocp-Apim-Subscription-Key' => '9******************************6',
为:
'Ocp-Apim-Subscription-Key: 9******************************6',