🎨 沙盒短网址
This commit is contained in:
parent
f32e0a21d3
commit
f764d61323
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue