首页 生男生女 生男生女示例代码 按照月份查性别[Java]

按照月份查性别示例代码[Java]

作者:xiezhongpian 阅读数:1218 上传时间:2017-05-09

按照月份查性别

package api.jisuapi.snsn;

import api.util.HttpUtil;
import net.sf.json.JSONObject;

public class Sex {

	public static final String APPKEY = "your_appkey_here";// 你的appkey
	public static final String URL = "https://api.jisuapi.com/snsn/sex";
	public static final String age = "18";
	public static final String month = "10";

	public static void Get() {
		String result = null;
		String url = URL + "?appkey=" + APPKEY + "&age=" + age + "&month=" + month;

		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 = (JSONObject) json.opt("result");
				String sex = resultarr.getString("sex");
				System.out.println(sex);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}