Problem in Google Translator API

I am translating a language using the Google Translator API.

Sometimes I get the following error.

Fatal error: Uncaught GTranslateException: [0]: Failed to complete Translation: Suspicious conditions for using the Service. See http://code.google.com/apis/errors cast in C: \ xampp \ htdocs \ MyProjectName \ public \ function \ GTranslate.php on line 263

Help me solve this problem.

Thanks in advance.

kanji.

+5
source share
2 answers

Subscribe to the Google API key at https://code.google.com/apis/console/ and activate the Google Translate API. Use the provided key in your project.

Google API , . // Google. , 100 . , 100 000 .

: , API.

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

google API Key https://code.google.com/apis/console/, .

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- . .

+3

All Articles