package api.jisuapi.caipiao; import api.util.HttpUtil; import net.sf.json.JSONArray; import net.sf.json.JSONObject; public class Query { public static final String APPKEY = "your_appkey_here";// 你的appkey public static final String URL = "https://api.jisuapi.com/caipiao/query"; public static final int caipiaoid = 13; public static final String issueno = ""; public static void Get() { String result = null; String url = URL + "?appkey=" + APPKEY + "&caipiaoid=" + caipiaoid + "&issueno=" + issueno; try { result = HttpUtil.sendGet(url, "utf-8"); JSONObject json = JSONObject.fromObject(result); if (json.getInt("status") != 0) { System.out.println(json.getString("msg")); } else { JSONObject resultarr = json.optJSONObject("result"); String caipiaoid = resultarr.getString("caipiaoid"); String issueno = resultarr.getString("issueno"); String number = resultarr.getString("number"); String refernumber = resultarr.getString("refernumber"); String opendate = resultarr.getString("opendate"); String deadline = resultarr.getString("deadline"); String saleamount = resultarr.getString("saleamount"); System.out.println(caipiaoid + " " + issueno + " " + number + " " + refernumber + " " + opendate + " " + deadline + " " + saleamount); if (resultarr.opt("prize") != null) { JSONArray prize = resultarr.optJSONArray("prize"); for (int i = 0; i < prize.size(); i++) { JSONObject obj = (JSONObject) prize.opt(i); String prizename = obj.getString("prizename"); String require = obj.getString("require"); String num = obj.getString("num"); String singlebonus = obj.getString("singlebonus"); System.out.println(prizename + " " + require + " " + num + " " + singlebonus); } } } } catch (Exception e) { e.printStackTrace(); } } }