5

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.

2
  • Are you hitting that service very often? It might think that you are trying to spam it.
    – the_drow
    Dec 9, 2010 at 6:14
  • Yes I have called this api while loding each page. That is the problem or what?
    – user455982
    Dec 9, 2010 at 6:42

2 Answers 2

3

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.

2

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);
4
  • But in my code, There is not any code to provide key (with activation key or anything). I have used gtranslate-api-php-0.7.6 this code and download it from code.google.com.
    – user455982
    Dec 9, 2010 at 11:30
  • @Kanji yes there is a place to provide a key: use the method GTranslate->setApiKey($api_key)
    – Mike C
    Dec 9, 2010 at 17:50
  • @Kanji, also, if you are using an API key, you can submit a request to Google to increase your daily limit
    – Mike C
    Dec 16, 2010 at 9:53
  • Some time this solution is also giving the same error. If you have another solution then please give..
    – user455982
    Apr 25, 2011 at 9:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.