luigimarmo / google-api-translate-java

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

Problem in translating #87

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Fail to set httpreferrer because i dont have any of my site.
Once set to localhost, it says: 

java.lang.Exception: [google-api-translate-java] Error retrieving 
translation.
        at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:123)
        at com.google.api.translate.Translate.execute(Translate.java:69)
        at speechdemo.TextToText.main(TextToText.java:42)
Caused by: java.net.UnknownHostException: ajax.googleapis.com
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:525)
        at java.net.Socket.connect(Socket.java:475)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
        at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
        at sun.net.www.http.HttpClient.New(HttpClient.java:306)
        at sun.net.www.http.HttpClient.New(HttpClient.java:323)
        at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient
(HttpURLConnection.java:860)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect
(HttpURLConnection.java:801)
        at sun.net.www.protocol.http.HttpURLConnection.connect
(HttpURLConnection.java:726)
        at sun.net.www.protocol.http.HttpURLConnection.getOutputStream
(HttpURLConnection.java:904)
        at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:107)

How to recover from it ??
Kindly help me out.

Original issue reported on code.google.com by anuragsa...@gmail.com on 27 Mar 2010 at 4:40

Attachments:

GoogleCodeExporter commented 9 years ago
I'm afraid Google requires setting a valid HTTP referrer. Unfortunately this 
requirement makes little sense in the context of a Java API, but it wasn't 
really 
designed for that.

FWIW, the API call should work with any valid web address even if it's not your 
site.

Original comment by rich.mid...@gmail.com on 27 Mar 2010 at 5:05