Question

I am doing Language translation using Google Translater API.

Sometimes I am getting following error.

Fatal error: Uncaught GTranslateException: [0]: Unable to perform Translation:Suspected Terms of Service Abuse. Please see http://code.google.com/apis/errors thrown in C:\xampp\htdocs\MyProjectName\public\function\GTranslate.php on line 263

Can anybody help me to fix this problem.

Thanks in advance.

Kanji.

Was it helpful?

Solution

Sign up for a Google API key at https://code.google.com/apis/console/ and activate the Google Translate API. Use the provided key in your project.

From the Google API Console page, follow on the traffic controls link on the left, then click the Configure Traffic Controls button. Increase the characters/second/user for Google Translate to something much larger than the default 100. Keep in mind you have a limit of 100,000 characters total per day.

Edit: as mentioned in my comment, this is how you would set the API key.

$apikey = 'xyz123';
$gt = new Gtranslate();
$gt->setApiKey($apikey);

OTHER TIPS

Sign up for google API Key at https://code.google.com/apis/console/ as mentioned earlier.

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();
}

Also consider to provide user IP address. This also can increase your daily limit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top