来自IP地址的Google Vision API请求被阻止

时间:2017-04-14 10:27:24

标签: php ocr google-vision

我使用Google Vision OCR通过​​PHP语言从图像中获取文本。 当我用了很长时间。我收到以下错误:

array(1) {
  ["error"]=>
  array(4) {
    ["code"]=>
    int(403)
    ["message"]=>
    string(53) "Requests from IP address ..... are blocked."
    ["status"]=>
    string(17) "PERMISSION_DENIED"
    ["details"]=>
    array(1) {
      [0]=>
      array(2) {
        ["@type"]=>
        string(35) "type.googleapis.com/google.rpc.Help"
        ["links"]=>
        array(1) {
          [0]=>
          array(2) {
            ["description"]=>
            string(32) "Google developer console API key"
            ["url"]=>
            string(75) "https://console.developers.google.com/project/191619933224/apiui/credential"
          }
        }
      }
    }
  }
}

请告诉我原因以及如何解决。 非常感谢。

1 个答案:

答案 0 :(得分:1)

检查您是否已授权Cloud API console中的API并按sample documentation中所述配置您的PHP客户端。

具体来说,请确保下载与您的愿景API项目相关联的credentials.json文件,并在运行示例之前将GOOGLE_APPLICATION_CREDENTIALS环境变量设置为凭据路径。