1
Google 번역 API를 처음 사용했습니다. 나는 단지 1 개의 요청 만 통과했다, 그리고 그것은 실패하기 시작했다. 일일 한도를 초과했다는 오류가 나타납니다. 내 결제 계정이 연결되어 있습니다. API가 활성화됩니다. 액세스 토큰이 생성되어 test 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'];
}
}
어떻게 부르시겠습니까? –
끝점에 도달했을 때이를 호출하는 경로가 있습니다. Route :: get ('get/translate', 'GoogleTranslateController @ translate'); 그래서 지금은 http : // localhost : 8000/get/translate로 테스트하여 테스트 결과를 얻습니다. –