|
|
|
@ -23,8 +23,10 @@ import (
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
"github.com/opesun/goquery"
|
|
|
|
|
"github.com/tidwall/gjson"
|
|
|
|
|
"io"
|
|
|
|
|
"io/ioutil"
|
|
|
|
|
"net/http"
|
|
|
|
|
"os"
|
|
|
|
|
"strconv"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
@ -542,9 +544,25 @@ func wxShowImg(context *gin.Context) {
|
|
|
|
|
p, err := goquery.ParseUrl(url)
|
|
|
|
|
if err != nil {
|
|
|
|
|
context.JSON(http.StatusOK, map[string]interface{}{"success": false, "imgSrc": "", "message": "获取微信图片发生异常!"})
|
|
|
|
|
return
|
|
|
|
|
} else {
|
|
|
|
|
imgSrc := p.Find("img").Attr("src")
|
|
|
|
|
imgSrc = `https://open.weixin.qq.com` + imgSrc
|
|
|
|
|
context.JSON(http.StatusOK, map[string]interface{}{"success": true, "imgSrc": imgSrc})
|
|
|
|
|
//下载文件到本地临时目录中
|
|
|
|
|
res, err := http.Get(imgSrc)
|
|
|
|
|
if err != nil {
|
|
|
|
|
context.JSON(http.StatusOK, map[string]interface{}{"success": false, "imgSrc": "", "message": "获取微信图片发生异常!"})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
//图片
|
|
|
|
|
pngFile := "/usr/local/dsMin/dsSso/Logs/" + CommonUtil.GetUUID() + ".png"
|
|
|
|
|
f, err := os.Create(pngFile)
|
|
|
|
|
if err != nil {
|
|
|
|
|
context.JSON(http.StatusOK, map[string]interface{}{"success": false, "imgSrc": "", "message": "获取微信图片发生异常!"})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
io.Copy(f, res.Body)
|
|
|
|
|
//提供图片
|
|
|
|
|
context.File(pngFile)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|