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_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=; mtcdn=K; wpush_server_url=wss://wpush.meituan.com; e_u_id_3299326472=e5ae16afe444349d24af7d33b66620a1; acctId=57396785; token=05dB_LgouAsXUZyajkn4BYPNqwhsIKOlpJVj8bCpWU_k*; 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=u1QwYRWkS6s4UbPe51pD2yxb39UkgViO2fo-eOwBX5KneNsBZsAPYAbAnl7IiE0b-MqLwRQRt7QwwU79IkPepA; cityId=510100; provinceId=510000; city_location_id=0; location_id=0; JSESSIONID=on9wehapo37eso6i98ot3p97; shopCategory=food; set_info=%7B%22wmPoiId%22%3A-1%2C%22ignoreSetRouterProxy%22%3Atrue%7D; cacheTimeMark=2021-03-15; pharmacistAccount=0; _lxsdk_s=17834f8e90f-c8b-674-c89%7C%7C19 ` 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)) }