The API package 'remote_socket' or call 'Resolve()' was not found - GAE Java

后端 未结 3 667
失恋的感觉
失恋的感觉 2021-01-28 08:03

I\'m trying to call a Google Service in a GAE application hosted in GAE cloud:

private String doPost(String URL) throws ClientProtocolException, IOException {
           


        
3条回答
  •  忘掉有多难
    2021-01-28 08:55

    Thanks!

    Solved with...

            URL url = new URL("https://www.google.com/accounts/ClientLogin");
    
            HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
            urlConnection.setRequestMethod("POST");
            urlConnection.setDoInput(true);
            urlConnection.setDoOutput(true);
            urlConnection.setUseCaches(false);
            urlConnection.setRequestProperty("Content-Type",
                                             "application/x-www-form-urlencoded");
    
            StringBuilder content = new StringBuilder();
            content.append("Email=").append(URLEncoder.encode(_DEFAULT_USER, "UTF-8"));
            content.append("&Passwd=").append(URLEncoder.encode(_DEFAULT_PASS, "UTF-8"));
            content.append("&service=").append(URLEncoder.encode("ah", "UTF-8"));
            OutputStream outputStream = urlConnection.getOutputStream();
            outputStream.write(content.toString().getBytes("UTF-8"));
            outputStream.close();
            // Response....
            int responseCode = urlConnection.getResponseCode();
            InputStream inputStream;
            if (responseCode == HttpURLConnection.HTTP_OK) {
              inputStream = urlConnection.getInputStream();
            } else {
              inputStream = urlConnection.getErrorStream();
            }
    

提交回复
热议问题