【问题标题】:Invalid Subscription key when using Face API使用人脸 API 时订阅密钥无效
【发布时间】:2017-07-07 12:59:09
【问题描述】:

我刚刚创建了一个人脸 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);

【问题讨论】:

    标签: php azure face-api


    【解决方案1】:

    您应该更改以下代码行:

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

    到:

    'Ocp-Apim-Subscription-Key: 9******************************6', 
    

    【讨论】:

      猜你喜欢
      • 2017-06-26
      • 2017-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-08
      • 2019-12-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多