diff --git a/main.go b/main.go index 6e79ad1..509d666 100644 --- a/main.go +++ b/main.go @@ -117,6 +117,7 @@ func supplyAccessToken(w http.ResponseWriter, r *http.Request) { } func iapiCreateWechatQrCode(w http.ResponseWriter, r *http.Request) { + logRequestDebug(httputil.DumpRequest(r, true)) if !checkSignatureByToken(r, IntraAPIConfig.CRMSecrete) { w.WriteHeader(http.StatusUnauthorized) fmt.Fprint(w, "unauthorized") diff --git a/qrcode.go b/qrcode.go index 58e7cd6..147b7fb 100644 --- a/qrcode.go +++ b/qrcode.go @@ -67,7 +67,7 @@ func createPermanentQR(value string) (result QRSrcInfo, err error) { func getURL4CreateQR() (URL string) { atk, _ := GetAccessToken() u := fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=%s", atk) - log.Println(u) + //log.Println(u) return u } @@ -80,7 +80,7 @@ func CreateTempQr(sceneID int32, expire int32) (result QRSrcInfo, err error) { s := QRTmpScene{} s.Name = "QR_SCENE" // s.Info.Scene.ID = sceneID - if expire <= 0 || expire >= 259200 { + if expire <= 0 || expire > 2592000 { log.Println("invalid expire time for Temp QR code, set to 30days instead") s.Expire = 2592000 } else { @@ -105,9 +105,10 @@ func qrImgByTicket(ticket string) (url string) { func iapiCreateTempQr(qr, expire int32) (jsonB []byte, err error) { if expire <= 0 { - expire = 30 //30 temp seconds only for 0 value + expire = 2592000 //30 days } info, err := CreateTempQr(qr, expire) + log.Println(info) if err == nil { jsonB, err = json.Marshal(info) } @@ -116,6 +117,7 @@ func iapiCreateTempQr(qr, expire int32) (jsonB []byte, err error) { func isapiCreatePermQr(qr string) (jsonB []byte, err error) { info, err := createPermanentQR(qr) + log.Println(info) if err == nil { jsonB, err = json.Marshal(info) } diff --git a/server_test.go b/server_test.go index 5d6a0db..8747d0a 100644 --- a/server_test.go +++ b/server_test.go @@ -111,7 +111,7 @@ func TestCreatePermenentWechatQr(t *testing.T) { func TestCreateTmpWechatQr(t *testing.T) { qrValue := int32(time.Now().Unix()) log.Println(qrValue) - qrExpire := int32(1200) + qrExpire := int32(0) req := buildReqTmpQr(qrValue, qrExpire) rr, _ := getHTTPResponse(req, iapiCreateWechatQrCode) m := rr.Body.String()