74 lines
2.8 KiB
Go
74 lines
2.8 KiB
Go
package mtwmapi
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.rosy.net.cn/baseapi"
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
var (
|
|
api *API
|
|
sugarLogger *zap.SugaredLogger
|
|
)
|
|
|
|
func init() {
|
|
logger, _ := zap.NewDevelopment()
|
|
sugarLogger = logger.Sugar()
|
|
baseapi.Init(sugarLogger)
|
|
|
|
// 菜市
|
|
api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
|
|
|
|
// 果园
|
|
// api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
|
|
|
|
//商超
|
|
// api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_tE0txRtx7CRuPIOjh2BH4w") //token_nH_IlcWQKAkZBqklwItNRw
|
|
cookieStr := `
|
|
__mta=188489239.1577327492709.1577327492709.1577327492709.1; uuid=e8034a4d222c4b51b81c.1574126611.1.0.0; _ga=GA1.2.827950563.1574128001; uuid_update=true; _lxsdk_cuid=16eb02a8a02c8-0a92cb9af9798c-3d375b01-15f900-16eb02a8a02c8; _lxsdk=16eb02a8a02c8-0a92cb9af9798c-3d375b01-15f900-16eb02a8a02c8; device_uuid=!aaa93749-2445-4e1e-b178-956ac0ea5e45; t_lxid=1719bfe9d5e30-0cf08957b60ff-3d375b01-15f900-1719bfe9d5fc8-tid; pushToken=0-AQeAm60pIt3VbpGu3MbPpMfRVaeCxP9tacRSFq7lmI*; lsu=; _gid=GA1.2.1480321802.1616033831; e_u_id_3299326472=e5ae16afe444349d24af7d33b66620a1; wpush_server_url=wss://wpush.meituan.com; acctId=57396785; token=0mSedih8udpe6yOnYDkGCYUi1ZoBjKT5Cvky4kBDolyA*; brandId=-1; wmPoiId=-1; isOfflineSelfOpen=0; city_id=0; isChain=1; existBrandPoi=true; ignore_set_router_proxy=true; region_id=; region_version=0; newCategory=true; bsid=yfpaaPKXj1BNDzKZXSLxpftf3dEnZ22uHvnqWXHKQ9ndFU5rb_YFk5vDi01MoEc6K91Ly6a6aqXT07tw1UI4Vg; cityId=510100; provinceId=510000; city_location_id=0; location_id=0; shopCategory=food; set_info=%7B%22wmPoiId%22%3A-1%2C%22ignoreSetRouterProxy%22%3Atrue%7D; cacheTimeMark=2021-03-18; JSESSIONID=8lgvdhuza3yi1gzvnefmo61t8; igateApp=shangouepc; pharmacistAccount=0; _lxsdk_s=17843d476fd-a90-21a-ca1%7C%7C29
|
|
`
|
|
api.SetCookieWithStr(cookieStr)
|
|
}
|
|
|
|
func TestAccessAPI(t *testing.T) {
|
|
result, err := api.AccessAPI("poi/getids", true, nil)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(utils.Format4Output(result, false))
|
|
}
|
|
|
|
func TestGetOAuthCode(t *testing.T) {
|
|
result, err := api.GetOAuthCode("10874383")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(utils.Format4Output(result, false))
|
|
}
|
|
|
|
func TestGetAccessToken(t *testing.T) {
|
|
result, err := api.GetAccessToken("code_nsX2gj8sQFcB0bYr0iVJtg")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(utils.Format4Output(result, false))
|
|
}
|
|
|
|
func TestGetAccessToken2(t *testing.T) {
|
|
result, err := api.GetAccessToken2("11011885") //refresh_token_pLG7Jw7g9mu7oOzNSuJIUg
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(utils.Format4Output(result, false))
|
|
}
|
|
|
|
func TestRefreshAccessToken(t *testing.T) {
|
|
result, err := api.RefreshAccessToken("refresh_token_jOp7ekeHrzjBUvLdVuZHIg") //token_qbAyE3ajWYT8ecwoI-FMjw
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(utils.Format4Output(result, false))
|
|
}
|