package main import ( "encoding/json" "fmt" "log" ) type QRLimitScene struct { Name string `json:"action_name"` Info struct { Scene struct { ID int32 `json:"scene_id"` IDstr string `json:"scene_str"` } `json:"scene"` } `json:"action_info"` } //CreateProfileEditQR, give user a temp password to login //for editing one's own profile func CreateProfileEditQR() { // http请求方式: POST // URL: https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=TOKENPOST数据格式:json // POST数据例子:{"action_name": "QR_LIMIT_SCENE", "action_info": {"scene": {"scene_id": 123}}} // 或者也可以使用以下POST数据创建字符串形式的二维码参数: // {"action_name": "QR_LIMIT_STR_SCENE", "action_info": {"scene": {"scene_str": "123"}}} u := getURL4QRPerm() s := QRLimitScene{} s.Name = "QR_LIMIT_SCENE" s.Info.Scene.IDstr = "edit_profile" j, _ := json.Marshal(s) log.Println(string(j)) postJSON(j, u) //{"ticket":"gQEm8DwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyS19UblE5Z3VjU2gxMDAwME0wM04AAgRMYh1ZAwQAAAAA","url":"http:\/\/weixin.qq.com\/q\/02K_TnQ9gucSh10000M03N"} //image: https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQEm8DwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyS19UblE5Z3VjU2gxMDAwME0wM04AAgRMYh1ZAwQAAAAA } func getURL4QRPerm() (URL string) { atk, _ := GetAccessToken() u := fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=%s", atk) log.Println(u) return u }