0
我刚刚创建了一个Face API密钥,并去了微软的测试console来测试它,但我得到了无效的密钥错误作为响应。我无法弄清楚如何将westus改为westcentralus,所以我放了一个小的PHP代码来发送请求。同样的错误。下面是代码:使用Face API时无效的订阅密钥
$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);