No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

45 líneas
1.4KB

  1. package main
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "log"
  6. )
  7. type QRLimitScene struct {
  8. Name string `json:"action_name"`
  9. Info struct {
  10. Scene struct {
  11. ID int32 `json:"scene_id"`
  12. IDstr string `json:"scene_str"`
  13. } `json:"scene"`
  14. } `json:"action_info"`
  15. }
  16. //CreateProfileEditQR, give user a temp password to login
  17. //for editing one's own profile
  18. func CreateProfileEditQR() {
  19. // http请求方式: POST
  20. // URL: https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=TOKENPOST数据格式:json
  21. // POST数据例子:{"action_name": "QR_LIMIT_SCENE", "action_info": {"scene": {"scene_id": 123}}}
  22. // 或者也可以使用以下POST数据创建字符串形式的二维码参数:
  23. // {"action_name": "QR_LIMIT_STR_SCENE", "action_info": {"scene": {"scene_str": "123"}}}
  24. u := getURL4QRPerm()
  25. s := QRLimitScene{}
  26. s.Name = "QR_LIMIT_SCENE"
  27. s.Info.Scene.IDstr = "edit_profile"
  28. j, _ := json.Marshal(s)
  29. log.Println(string(j))
  30. postJSON(j, u)
  31. //{"ticket":"gQEm8DwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyS19UblE5Z3VjU2gxMDAwME0wM04AAgRMYh1ZAwQAAAAA","url":"http:\/\/weixin.qq.com\/q\/02K_TnQ9gucSh10000M03N"}
  32. //image: https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQEm8DwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyS19UblE5Z3VjU2gxMDAwME0wM04AAgRMYh1ZAwQAAAAA
  33. }
  34. func getURL4QRPerm() (URL string) {
  35. atk, _ := GetAccessToken()
  36. u := fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=%s", atk)
  37. log.Println(u)
  38. return u
  39. }