<?php
require_once 'curl.func.php';
$appkey = 'your_appkey_here';//你的appkey
$sex = 'male';//male famale
$height = 172;//cm
$weight = 60;//kg
$url = "https://api.jisuapi.com/weight/bmi?appkey=$appkey&sex=$sex&height=$height&weight=$weight";
$result = curlOpen($url, ['ssl'=>true]);
$jsonarr = json_decode($result, true);
//exit(var_dump($jsonarr));
if($jsonarr['status'] != 0)
{
echo $jsonarr['msg'];
exit();
}
$result = $jsonarr['result'];
echo $result['bmi'].' '.$result['normbmi'].' '.$result['idealweight'].' '.$result['level'].' '.$result['danger'].' '.$result['status'].' '.'
';
#!/usr/bin/python
# encoding:utf-8
import urllib2, json, urllib
# 1、标准体重
data = {}
data["appkey"] = "your_appkey_here"
data["weight"] = 52
data["height"] = 170
data["sex"] = "male" #famale
url_values = urllib.urlencode(data)
url = "https://api.jisuapi.com/weight/bmi" + "?" + url_values
request = urllib2.Request(url)
result = urllib2.urlopen(request)
jsonarr = json.loads(result.read())
if jsonarr["status"] != u"0":
print jsonarr["msg"]
exit()
result = jsonarr["result"]
print result["bmi"],result["normbmi"],result["idealweight"],result["level"],result["danger"],result["status"]
package api.jisuapi.weight;
import api.util.HttpUtil;
import net.sf.json.JSONObject;
public class Bmi {
public static final String APPKEY = "your_appkey_here";// 你的appkey
public static final String URL = "https://api.jisuapi.com/weight/bmi";
public static final String sex = "male";// male famale
public static final String height = "172";// cm
public static final String weight = "60";// kg
public static void Get() {
String result = null;
String url = URL + "?appkey=" + APPKEY + "&sex=" + sex + "&height=" + height + "&weight=" + weight;
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 bmi = resultarr.getString("bmi");
String normbmi = resultarr.getString("normbmi");
String idealweight = resultarr.getString("idealweight");
String level = resultarr.getString("level");
String danger = resultarr.getString("danger");
String status = resultarr.getString("status");
System.out.println(bmi + " " + normbmi + " " + idealweight + " " + level + " " + danger + " " + status);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}