From f764d6132312ebe5ebc93f4f7ff97724b9e40e31 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Fri, 17 May 2019 13:14:46 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=B2=99=E7=9B=92=E7=9F=AD=E7=BD=91?= =?UTF-8?q?=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- playground/file.go | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/playground/file.go b/playground/file.go index f365f49..2fcf8e7 100644 --- a/playground/file.go +++ b/playground/file.go @@ -23,7 +23,6 @@ import ( "os" "os/exec" "path/filepath" - "strings" "github.com/b3log/wide/conf" "github.com/b3log/wide/session" @@ -116,23 +115,24 @@ func ShortURLHandler(w http.ResponseWriter, r *http.Request) { return } - url := args["url"].(string) + result.Data = args["url"].(string) - resp, _ := http.Post("http://dwz.cn/create.php", "application/x-www-form-urlencoded", - strings.NewReader("url="+url)) - - var response map[string]interface{} - if err := json.NewDecoder(resp.Body).Decode(&response); err != nil { - logger.Error(err) - result.Succ = false - - return - } - - shortURL := url - if 0 == response["status"].(float64) { - shortURL = response["tinyurl"].(string) - } - - result.Data = shortURL + // 百度短网址服务需要认证才可以使用 + //resp, _ := http.Post("http://dwz.cn/create.php", "application/x-www-form-urlencoded", + // strings.NewReader("url="+url)) + // + //var response map[string]interface{} + //if err := json.NewDecoder(resp.Body).Decode(&response); err != nil { + // logger.Error(err) + // result.Succ = false + // + // return + //} + // + //shortURL := url + //if 0 == response["status"].(float64) { + // shortURL = response["tinyurl"].(string) + //} + // + //result.Data = shortURL }