小さなテキストがポジティブ、ネガティブ、ニュートラルのいずれであるかを見つけるために、Sentiment-140が提供するパブリックAPIを使用しています。単純なHTTP-JSONサービスは正常に使用できますが、CURLで失敗します。これが私のコードです:
public static void makeCURL(String jsonData) throws MalformedURLException, ProtocolException, IOException {
byte[] queryData = jsonData.getBytes("UTF-8");
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("10.1.1.1", 8080));
HttpURLConnection con = (HttpURLConnection) new URL("http://www.sentiment140.com/api/bulkClassifyJson").openConnection(proxy);
con.setRequestMethod("POST");
con.setDoOutput(true);
OutputStream os = con.getOutputStream();
InputStream instr = con.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(instr));
os.write(queryData);
os.close();
String lin;
while((lin = br.readLine())!=null){
System.out.println("[Debug]"+lin); // I expect some response here But it's not showing anything
}
}
私は何が間違っているのですか?