我正在使用 Google Translater API 进行语言翻译。
有时我会遇到以下错误。
fatal error :未捕获 GTranslateException:[0]:无法执行翻译:涉嫌滥用服务条款。请看http://code.google.com/apis/errors在第 263 行抛出 C:\xampp\htdocs\MyProjectName\public\function\GTranslate.php
谁能帮我解决这个问题。
提前致谢。
汉字。
最佳答案
在 https://code.google.com/apis/console/ 注册谷歌 API key 如前面提到的。
require_once("GTranslate.php");
try{
$gt = new Gtranslate();
$gt->setApiKey('YOUR_GOOGLE_API_KEY');
$gt->setUserIp($_SERVER['REMOTE_ADDR']);
echo $gt->english_to_german("hello world");
} catch (GTranslateException $ge)
{
echo $ge->getMessage();
}
同时考虑提供用户IP地址。这也会增加您的每日限额。
关于php - Google 翻译 API 中的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4395407/