0

I've just created a Face API key and went to Microsoft's test console to test it out but I get invalid key error as response. I could not figure out how to change westus to westcentralus so I put together a small PHP code to send the request. The same error. Here is the code:

$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);

enter image description here

kemkriszt
  • 280
  • 3
  • 17

1 Answers1

0

You should change the following line of code:

'Ocp-Apim-Subscription-Key' => '9******************************6', 

to:

'Ocp-Apim-Subscription-Key: 9******************************6', 
Aaron Chen
  • 9,835
  • 1
  • 16
  • 28