{ "code": 1, "msg": "数据返回成功!", "data": { "foodId": "befa2163948534a9", "name": "鲜玉米", "calory": "112.0", "caloryUnit": "千卡", "joule": "468.61", "jouleUnit": "千焦", "protein": "4.0", "proteinUnit": "克", "fat": "1.2", "fatUnit": "克", "saturatedFat": "0.0", "saturatedFatUnit": "克", "fattyAcid": "", "fattyAcidUnit": "克", "mufa": "0.0", "mufaUnit": "克", "pufa": "0.0", "pufaUnit": "克", "cholesterol": "0.0", "cholesterolUnit": "毫克", "carbohydrate": "22.8", "carbohydrateUnit": "克", "sugar": "", "sugarUnit": "克", "fiberDietary": "2.9", "fiberDietaryUnit": "克", "natrium": "1.1", "natriumUnit": "毫克", "alcohol": "0.0", "alcoholUnit": "%vol", "vitaminA": "0.0", "vitaminAUnit": "微克RAE", "carotene": "0.0", "caroteneUnit": "微克", "vitaminD": "0.0", "vitaminDUnit": "微克", "vitaminE": "0.0", "vitaminEUnit": "微克", "vitaminK": "0.0", "vitaminKUnit": "微克", "thiamine": "0.16", "thiamineUnit": "毫克", "lactoflavin": "0.11", "lactoflavinUnit": "毫克", "vitaminB6": "0.0", "vitaminB6Unit": "毫克", "vitaminB12": "0.0", "vitaminB12Unit": "微克", "vitaminC": "16.0", "vitaminCUnit": "毫克", "niacin": "1.8", "niacinUnit": "毫克", "folacin": "31.9", "folacinUnit": "微克", "pantothenic": "0.0", "pantothenicUnit": "毫克", "biotin": "0.0", "biotinUnit": "微克", "choline": "0.0", "cholineUnit": "毫克", "phosphor": "117.0", "phosphorUnit": "毫克", "kalium": "238.0", "kaliumUnit": "毫克", "magnesium": "32.0", "magnesiumUnit": "毫克", "calcium": "0.0", "calciumUnit": "毫克", "iron": "1.1", "ironUnit": "毫克", "zinc": "0.9", "zincUnit": "毫克", "iodine": "1.1", "iodineUnit": "微克", "selenium": "1.63", "seleniumUnit": "微克", "copper": "0.09", "copperUnit": "毫克", "fluorine": "", "fluorineUnit": "毫克", "manganese": "0.22", "manganeseUnit": "毫克", "healthLight": 1, "healthTips": "绿灯食物", "healthSuggest": "推荐食用", "glycemicInfoData": { "gi": { "value": "55.0", "label": "中GI" }, "gl": { "value": "10.9", "label": "中GL" } } } }
<?php /** * Created by PhpStorm. * User: FZS * Time: 2022/11/03 09:56 */ class freeApi { private $apiUrl; public function __construct() { $this->apiUrl = 'https://www.mxnzp.com/api/food_heat/food/details?foodId=your&app_id=your&app_secret=your'; } /** * 获取结果 * @return array */ public function getResult() { return file_get_contents($this->apiUrl); } }
package main import ( "fmt" "io/ioutil" "log" "net/http" ) const ( APIURL = "https://www.mxnzp.com/api/food_heat/food/details?foodId=your&app_id=your&app_secret=your" ) func main() { queryUrl := fmt.Sprintf("%s",APIURL) resp, err := http.Get(queryUrl) if err != nil { log.Println(err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body)) }