You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.3 KiB
46 lines
1.3 KiB
3 years ago
|
package meituan
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
2 years ago
|
gorequest "go.dtapp.net/library/gorequest"
|
||
3 years ago
|
"net/http"
|
||
|
)
|
||
|
|
||
|
type PoiAreaResponse struct {
|
||
|
Code int `json:"code"`
|
||
|
Data []struct {
|
||
|
Area []struct {
|
||
|
Name string `json:"name"` // 商圈名称
|
||
|
ID int `json:"id"` // 商圈id
|
||
|
} `json:"area"`
|
||
|
Name string `json:"name"` // 行政区名称
|
||
|
ID int `json:"id"` // 行政区id
|
||
|
} `json:"data"`
|
||
|
}
|
||
|
|
||
|
type PoiAreaResult struct {
|
||
2 years ago
|
Result PoiAreaResponse // 结果
|
||
|
Body []byte // 内容
|
||
|
Http gorequest.Response // 请求
|
||
|
Err error // 错误
|
||
3 years ago
|
}
|
||
|
|
||
2 years ago
|
func NewPoiAreaResult(result PoiAreaResponse, body []byte, http gorequest.Response, err error) *PoiAreaResult {
|
||
|
return &PoiAreaResult{Result: result, Body: body, Http: http, Err: err}
|
||
3 years ago
|
}
|
||
|
|
||
|
// PoiArea 基础数据 - 商圈接口
|
||
|
// https://openapi.meituan.com/#api-0.%E5%9F%BA%E7%A1%80%E6%95%B0%E6%8D%AE-GetHttpsOpenapiMeituanComPoiAreaCityid1
|
||
|
func (app *App) PoiArea(cityID int) *PoiAreaResult {
|
||
|
// 参数
|
||
2 years ago
|
param := gorequest.NewParams()
|
||
3 years ago
|
param.Set("cityid", cityID)
|
||
2 years ago
|
params := gorequest.NewParamsWith(param)
|
||
3 years ago
|
// 请求
|
||
2 years ago
|
request, err := app.request("https://openapi.meituan.com/poi/area", params, http.MethodGet)
|
||
3 years ago
|
// 定义
|
||
|
var response PoiAreaResponse
|
||
2 years ago
|
err = json.Unmarshal(request.ResponseBody, &response)
|
||
|
return NewPoiAreaResult(response, request.ResponseBody, request, err)
|
||
3 years ago
|
}
|