CentOS上で、JAVAです。※開発は、Win10上。
※JAVA,JSP、MySQL、Aptch, tomcat、ecilpsなどなど色々動いています。
アップルストアで購入されたときのレシートの確認プログラムの
サンプルを見つけたのですが、下記をjAVAソースへ貼り付けると、
下記の変数やクラスが、eclipsで赤く表示され存在しないとなります。
どうすれば、これらを使えるようになりますか?
・HttpClient httpClient
・IOUtils.
・HttpPost
・HttpClientParams
・log
・JSONObject
・WebApplicationException
・Response
・status
// アップルストアで購入時にレシートをチェックする。 public boolean check_appstore_itunes_receipt() { try { String url = "https://buy.itunes.apple.com/verifyReceipt"; HttpClient httpClient = new DefaultHttpClient(); DefaultHttpClient client = null; try { String input = IOUtils.toString(is); log.info("THE INPUTSTREAM: " + input); JSONObject receipt = new JSONObject(); receipt.put("receipt-data", input); client = new DefaultHttpClient(); HttpPost post = new HttpPost(url); StringEntity entity = new StringEntity(receipt.toString()); entity.setContentType("application/json"); post.setEntity(entity); HttpClientParams.setRedirecting(post.getParams(), false); HttpResponse response = client.execute(post); if (300 <= response.getStatusLine().getStatusCode()) { throw new RuntimeException("No response from iTune store. status code: " + response.getStatusLine().getStatusCode()); } if (null == response.getEntity()) { log.info("Response is null"); throw new Exception("Response is null"); } StringBuilder sb = new StringBuilder(); BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); for (String line; null != (line = reader.readLine());) { sb.append(line); } JSONObject json = new JSONObject(sb.toString()); log.info("THE JSON" + json); //Then work with json below } catch (Exception e) { throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(e.getMessage()).build()); } finally { if (null != client) { client.getConnectionManager().shutdown(); } }
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。