nidhipanchal2207 / google-api-translate-java

Automatically exported from code.google.com/p/google-api-translate-java
0 stars 0 forks source link

Use google-api-translate-java but error #164

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
I've created following class in the eclipse
package com.translate;

import com.google.api.GoogleAPI;
import com.google.api.GoogleAPIException;
import com.google.api.translate.Language;
import com.google.api.translate.Translate;

public class aaa {

    public static void main(String[] args) throws Exception {

        GoogleAPI.setHttpReferrer("http://www.google.com");
        GoogleAPI.setKey("AIzaSyAhwmTOURyWNpx2jrfnCpMywejOSwlpVa8");
        try {
            String translatedText = Translate.DEFAULT.execute("Hello",
                    Language.ENGLISH, Language.CHINESE_TRADITIONAL);

            System.out.println(translatedText);
        } catch (GoogleAPIException e) {
            e.printStackTrace();
        }

    }

}
I'm trying to use google-api-translate-java api but error.

What is the expected output? What do you see instead?
expected output:你好
but see error:

Error: [google-api-translate-java] Error retrieving translation.
com.google.api.GoogleAPIException: java.lang.Exception: 
[google-api-translate-java] Error retrieving translation.
    at com.google.api.translate.TranslateV2.execute(TranslateV2.java:68)
    at com.translate.aaa.main(aaa.java:20)
Caused by: java.lang.Exception: [google-api-translate-java] Error retrieving 
translation.
    at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:99)
    at com.google.api.translate.TranslateV2.execute(TranslateV2.java:62)
    ... 1 more
Caused by: java.io.IOException: Server returned HTTP response code: 403 for 
URL: 
https://www.googleapis.com/language/translate/v2?key=AIzaSyAhwmTOURyWNpx2jrfnCpM
ywejOSwlpVa8&q=Hello&target=zh-TW&source=en
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
    at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:93)
    ... 2 more
Caused by: java.io.IOException: Server returned HTTP response code: 403 for 
URL: 
https://www.googleapis.com/language/translate/v2?key=AIzaSyAhwmTOURyWNpx2jrfnCpM
ywejOSwlpVa8&q=Hello&target=zh-TW&source=en
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
    at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:89)
    ... 2 more

What version of the product are you using? On what operating system?

google-api-translate-java-0.97.jar
windows 7 professional x64

Original issue reported on code.google.com by a18193...@gmail.com on 7 Mar 2012 at 12:38

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Even I am also getting this error. Did you resolve this error?

Original comment by anura.mo...@gmail.com on 26 Jul 2012 at 9:25

GoogleCodeExporter commented 8 years ago
Did you checkout this service? I thought it's free but actually not, so check 
this one first and try again maybe can work ,or consider using Microsoft BING 
translator It's free by translating 500,000 word/month :D

Original comment by a18193...@gmail.com on 26 Jul 2012 at 5:10

GoogleCodeExporter commented 8 years ago
I am also having the same error:

code: 403,
message: "Access Not Configured"

Is there anyone who found solution to it?

Original comment by nawani.v...@gmail.com on 22 Jan 2013 at 5:36

GoogleCodeExporter commented 8 years ago
i am getting the same error

Original comment by paramesh...@gmail.com on 4 Dec 2014 at 4:52