import ( "fmt" "net/http" "net/url" )

const g_url = "https://api.weixin.qq.com/wxa/launch_liteapp?appid=wx2317470564&version=1.0.0"

func launchApp(sessionKey string, appId string, uin string, query url.Values, path string, env string) bool { params := url.Values{} params.Set('sessionKey', sessionKey) params.Set('appId', appId) params.Set('uin', uin) params.Set('env', env)

if path != "" {
	entry := path
	if query != nil {
		entry += '?' + query.Encode()
	}
	params.Set('entry', entry)
}

req, err := http.NewRequest("GET", g_url, nil)
if err != nil {
	fmt.Println(err)
	return false
}

req.URL.RawQuery = params.Encode()

res, err := http.DefaultClient.Do(req)
if err != nil {
	fmt.Println(err)
	return false
}

defer res.Body.Close()

if res.StatusCode == 200 {
	errCode := res.JSON()['errCode']
	if errCode == 0 {
		return true
	} else {
		fmt.Printf('%s, %d, %s', res.URL, res.StatusCode, res.Body)
	}
} else {
	fmt.Printf('%s, %d, %s', res.URL, res.StatusCode, res.Body)
}

return false

}

Golang 实现 Python 微信小程序启动代码

原文地址: https://www.cveoy.top/t/topic/oiff 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录