接口地址:https://www.mxnzp.com/api/rubbish/type |
---|
返回格式:json |
请求方式:get |
请求示例:https://www.mxnzp.com/api/rubbish/type?name=西瓜&app_id=you&app_secret=you |
名称 | 类型 | 必填 | 说明 |
---|---|---|---|
app_id | string | 必填 | app_id 扫码关注公众号 |
app_secret | string | 必填 | app_secret 扫码关注公众号 |
name | string | 必填 | 物品名称 |
名称 | 类型 | 说明 |
---|---|---|
aim | string | 查询出来的匹配结果 |
goodsName | string | 物品名称 |
goodsType | string | 物品垃圾分类类型 |
recommendList | string | 推荐查询结果 |
{
"code": 1,
"msg": "数据返回成功!",
"data": {
"aim": {
"goodsName": "西瓜",
"goodsType": "湿垃圾"
},
"recommendList": [{
"goodsName": "西瓜皮",
"goodsType": "湿垃圾"
}, {
"goodsName": "包裹着西瓜籽的纸巾",
"goodsType": "干垃圾"
}, {
"goodsName": "西瓜籽",
"goodsType": "湿垃圾"
}, {
"goodsName": "西瓜子",
"goodsType": "湿垃圾"
}]
}
}
错误码 | 说明 |
---|---|
0 | app_id或者app_secret不合法 |
<?php
/**
* Created by PhpStorm.
* User: FZS
* Time: 2022/09/19 14:56
*/
class freeApi
{
private $apiUrl;
public function __construct()
{
$this->apiUrl = 'https://www.mxnzp.com/api/rubbish/type?name=西瓜&app_id=you&app_secret=you';
}
/**
* 获取结果
* @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/rubbish/type?name=西瓜&app_id=you&app_secret=you"
)
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))
}