{ "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" }] } }
<?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)) }