🎨 沙盒短网址

This commit is contained in:
Liang Ding 2019-05-17 13:14:46 +08:00
parent f32e0a21d3
commit f764d61323
No known key found for this signature in database
GPG Key ID: 136F30F901A2231D
1 changed files with 19 additions and 19 deletions

View File

@ -23,7 +23,6 @@ import (
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"strings"
"github.com/b3log/wide/conf" "github.com/b3log/wide/conf"
"github.com/b3log/wide/session" "github.com/b3log/wide/session"
@ -116,23 +115,24 @@ func ShortURLHandler(w http.ResponseWriter, r *http.Request) {
return 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)) //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 { //var response map[string]interface{}
logger.Error(err) //if err := json.NewDecoder(resp.Body).Decode(&response); err != nil {
result.Succ = false // logger.Error(err)
// result.Succ = false
return //
} // return
//}
shortURL := url //
if 0 == response["status"].(float64) { //shortURL := url
shortURL = response["tinyurl"].(string) //if 0 == response["status"].(float64) {
} // shortURL = response["tinyurl"].(string)
//}
result.Data = shortURL //
//result.Data = shortURL
} }