package api.jisuapi.caipiao;
import api.util.HttpUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
public class History {
public static final String APPKEY = "your_appkey_here";// 你的appkey
public static final String URL = "https://api.jisuapi.com/caipiao/history";
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");
System.out.println(caipiaoid);
if (resultarr.opt("list") != null) {
JSONArray list = resultarr.optJSONArray("list");
for (int j = 0; j < list.size(); j++) {
JSONObject list_ = (JSONObject) list.opt(j);
String opendate = list_.getString("opendate");
String issueno = list_.getString("issueno");
String number = list_.getString("number");
String refernumber = list_.getString("refernumber");
String saleamount = list_.getString("saleamount");
System.out.println(
opendate + " " + issueno + " " + number + " " + refernumber + " " + saleamount);
if (list_.opt("prize") != null) {
JSONArray prize = list_.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();
}
}
}