2017-09-11 134 views
1

我是使用Google Translate API的新用戶。我只收到1個請求,然後開始失敗。我收到超出每日限額的錯誤。我的結算帳戶已關聯並啓用。 api已啓用。訪問令牌已創建,並且正在通過測試cURL請求工作。403 Google翻譯API超出每日限制

這是我爲我的測試方法的代碼:

<?php 

namespace App\Http\Controllers; 

use Illuminate\Http\Request; 

# Imports the Google Cloud client library 
use Google\Cloud\Translate\TranslateClient; 

class GoogleTranslateController extends Controller 
{ 

    # Your Google Cloud Platform project ID 
    private $projectId = 'my_project_id'; 

    public function translate() 
    { 

    //$content, $targetLanguage 
    # Instantiates a client 
      $translate = new TranslateClient([ 
       'projectId' => $this->projectId 
      ]); 

    # The text to translate 
      $text = 'Hello, world!'; 
    # The target language 
      $target = 'es'; 

    # Translates some text into Russian 
      $translation = $translate->translate($text, [ 
       'target' => $target 
      ]); 

     return $translation['text']; 
    } 


} 
+0

你是怎麼稱呼它的? –

+0

我有一個路由,當我打到端點時會調用它。路線::得到( '獲得/翻譯', 'GoogleTranslateController @翻譯');所以現在我正在使用http:// localhost:8000/get/translate進行測試以獲得測試輸出 –

回答

0

今天嘗試它後,API的工作。我不知道是否有時間延遲激活或不。我之前有過其他Google Api的問題。

相關問題