|
@@ -4,13 +4,53 @@ package weixin
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
- "github.com/SKatiyar/qr"
|
|
|
"log"
|
|
|
"net/http"
|
|
|
"qfw/util"
|
|
|
"strconv"
|
|
|
+
|
|
|
+ "github.com/SKatiyar/qr"
|
|
|
)
|
|
|
|
|
|
+//生成永久二维码
|
|
|
+func YjHandle_Img(w http.ResponseWriter, r *http.Request) {
|
|
|
+ param := r.RequestURI[12:]
|
|
|
+ if !digitreg.MatchString(param) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ log.Println("param:", param)
|
|
|
+ //TODO 参数存redis
|
|
|
+ iparam, _ := strconv.Atoi(param)
|
|
|
+ //构造自定义消息文本
|
|
|
+ var msg struct {
|
|
|
+ Name string `json:"action_name"`
|
|
|
+ Info struct {
|
|
|
+ Scene struct {
|
|
|
+ Id int `json:"scene_id"`
|
|
|
+ } `json:"scene"`
|
|
|
+ } `json:"action_info"`
|
|
|
+ }
|
|
|
+ msg.Name = "QR_LIMIT_SCENE"
|
|
|
+ msg.Info.Scene.Id = iparam
|
|
|
+ ret, err := Mux.PostCustomMsg("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=", &msg)
|
|
|
+ if err != nil {
|
|
|
+ log.Println(err.Error())
|
|
|
+ } else {
|
|
|
+ tmp := map[string]interface{}{}
|
|
|
+ json.Unmarshal(ret, &tmp)
|
|
|
+ log.Println(tmp)
|
|
|
+ url := tmp["url"].(string)
|
|
|
+ w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
|
|
+ w.Header().Set("Pragma", "no-cache")
|
|
|
+ w.Header().Set("Expires", "0")
|
|
|
+ w.Header().Set("Content-Type", "image/png")
|
|
|
+ r, _ := qr.Encode(url, qr.L)
|
|
|
+ pngdat := r.PNG()
|
|
|
+ w.Write(pngdat)
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
//生成永久二维码
|
|
|
func YjHandle(w http.ResponseWriter, r *http.Request) {
|
|
|
param := r.RequestURI[12:]
|