接口地址:https://www.mxnzp.com/api/food_heat/food/search |
---|
返回格式:json |
请求方式:get |
请求示例:https://www.mxnzp.com/api/food_heat/food/search?keyword=苹果&page=1&app_id=your&app_secret=your |
名称 | 类型 | 必填 | 说明 |
---|---|---|---|
app_id | string | 必填 | app_id 扫码关注公众号 |
app_secret | string | 必填 | app_secret 扫码关注公众号 |
keyword | string | 必填 | 食物名称 |
page | int | 选填 | 分页页数 |
名称 | 类型 | 说明 |
---|---|---|
foodId | string | 食物id,后续查询食物详情需要 |
name | string | 食物名称 |
healthLevel | string | 健康等级 1 2 3 分别是推荐 适量 少吃 |
calory | string | 热量/千卡/100g/100ml |
{
"code": 1,
"msg": "数据返回成功!",
"data": {
"page": 1,
"totalCount": 2113,
"totalPage": 212,
"limit": 10,
"list": [{
"foodId": "5a4aa4442b9f5d97",
"name": "苹果",
"healthLevel": 1,
"calory": "53.0"
}, {
"foodId": "d3607294c2a363fc",
"name": "苹果蕉",
"healthLevel": 1,
"calory": "90.0"
}, {
"foodId": "14ead7edd07f9bbf",
"name": "木苹果",
"healthLevel": 2,
"calory": "134.0"
}, {
"foodId": "78bc5e0d00229c70",
"name": "星苹果",
"healthLevel": 1,
"calory": "67.2"
}, {
"foodId": "1c42e2dc1eaec59b",
"name": "苹果汁",
"healthLevel": 2,
"calory": "23.0"
}, {
"foodId": "da7e701ff97310ce",
"name": "苹果梨",
"healthLevel": 1,
"calory": "53.0"
}, {
"foodId": "b2d252e6742cf803",
"name": "伏苹果",
"healthLevel": 1,
"calory": "48.0"
}, {
"foodId": "2a70671f6545f378",
"name": "蒸苹果",
"healthLevel": 1,
"calory": "35.33"
}, {
"foodId": "15348968ec01a233",
"name": "青苹果",
"healthLevel": 1,
"calory": "49.0"
}, {
"foodId": "8c79ca0b45f28f8a",
"name": "旱苹果",
"healthLevel": 1,
"calory": "34.0"
}]
}
}
错误码 | 说明 |
---|---|
0 | app_id或者app_secret不合法 |
<?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/search?keyword=苹果&page=1&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/search?keyword=苹果&page=1&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))
}