百度地圖sn驗證golang實現

t65011223發表於2018-12-13
func TestNewserviceBaiduPOI(t *testing.T) {
	//http://api.map.baidu.com/geocoder/v2/?address=百度大廈&output=json&ak=yourak +sk碼
	h := "http://api.map.baidu.com"
	path := "/geocoder/v2/"
	data := url.Values{}
	data.Add("address", "百度大廈")
	data.Add("output", "json")
	data.Add("ak", yourak)
	o := path + "?" + data.Encode() + sk碼
	hash := md5.New()
	hash.Write([]byte(url.QueryEscape(o)))
	sn := hex.EncodeToString(hash.Sum(nil))
	data.Add("sn", sn)
	url := h + path + "?" + data1.Encode()
	log.Info(url)
}

相關文章