本文整理汇总了Golang中github.com/astaxie/beego/httplib.Get函数的典型用法代码示例。如果您正苦于以下问题:Golang Get函数的具体用法?Golang Get怎么用?Golang Get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
log := logs.NewLogger(10000)
log.SetLogger("file", `{"filename":"/tmp/wallpaper.log"}`)
log.Info("Start===================")
v := Bing{}
req := httplib.Get("http://www.bing.com/HPImageArchive.aspx?format=json&idx=0&n=1")
err := req.ToXml(&v)
if len(v.Images) > 0 && err == nil {
pic := httplib.Get(bingURL + v.Images[0].Url)
fmt.Println(file_path)
err = pic.ToFile(file_path)
if err != nil {
log.Error("save file error %v.............", err)
} else {
log.Info("download wallpeper success..........")
cmd := exec.Command("gsettings", "set", "org.gnome.desktop.background", "picture-uri", fmt.Sprintf("file:%s", file_path))
err := cmd.Start()
log.Info("Waiting for command to finish.........")
err = cmd.Wait()
log.Info("Command finished with error: %v", err)
if err != nil {
log.Error("%v............", err)
}
log.Info("set wallpeper success..........")
}
}
log.Info("End===================")
}
示例2: Logout
func Logout(sig string) error {
uri := fmt.Sprintf("%s/sso/logout/%s", UicInternal, sig)
req := httplib.Get(uri)
req.Param("token", Token)
_, err := req.String()
return err
}
示例3: Get
func (this *ContectController) Get() {
req := httplib.Get("http://acg.178.com/")
str, err := req.String()
if err != nil {
}
this.Ctx.WriteString(str)
}
示例4: GetUser
func GetUser(sig string) (*User, error) {
key := fmt.Sprintf("u:%s", sig)
u := g.Cache.Get(key)
if u != nil {
uobj := u.(User)
return &uobj, nil
}
uri := fmt.Sprintf("%s/sso/user/%s", g.UicInternal, sig)
req := httplib.Get(uri)
req.Param("token", g.Token)
resp, err := req.Response()
if err != nil {
return nil, err
}
if resp.StatusCode != 200 {
return nil, fmt.Errorf("StatusCode: %d", resp.StatusCode)
}
decoder := json.NewDecoder(resp.Body)
type TmpStruct struct {
User *User `json:"user"`
}
var t TmpStruct
err = decoder.Decode(&t)
if err != nil {
return nil, err
}
// don't worry cache expired. we just use username which can not modify
g.Cache.Put(key, *t.User, int64(360000))
return t.User, nil
}
示例5: DeleteContainerUserFromProxy
func DeleteContainerUserFromProxy(rulelist []SshRule, logid int64) error {
logs.Normal("delete container from proxy:", rulelist, "logid:", logid)
token := beego.AppConfig.String("proxy_url_token")
//userdel
for _, sshRuleOb := range rulelist {
container := sshRuleOb.ContainerName
proxyHost := sshRuleOb.ProxyHost
//this url todo
proxyDelUrl := proxyHost + ":9090/deleteContainer?container=" + container + "&logid=" + strconv.FormatInt(logid, 10) + "&token=" + token
logs.Normal("curl delete container url:", proxyDelUrl, "logid:", logid)
req := httplib.Get(proxyDelUrl)
output := make(map[string]interface{})
err := req.ToJson(&output)
if err != nil {
logs.Error("request from "+proxyDelUrl+" error:", err, logid)
return err
}
if output["result"].(int) == 0 {
logs.Normal(proxyDelUrl, "response ok!", logid)
continue
} else {
logs.Error(proxyDelUrl+" error:", output["error"], logid)
}
}
return nil
}
示例6: fetch
func fetch(videoUrl string) {
req := httplib.Get(videoUrl)
resp, err := req.Response()
if err != nil {
fmt.Println("fetch video url error,", err)
return
}
defer resp.Body.Close()
respData, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("read video url content error,", err)
return
}
pattern := `flashvars="list=.*"`
regx := regexp.MustCompile(pattern)
flashVars := regx.FindString(string(respData))
if flashVars != "" {
size := len(flashVars)
m3u8Url, err := url.QueryUnescape(flashVars[16 : size-1])
if err != nil {
fmt.Println(err)
} else {
fetchMovie(m3u8Url)
}
} else {
fmt.Println("m3u8 playlist not found")
}
}
示例7: httpsqsQueue
// 队列操作
func httpsqsQueue(px string) url.Values {
hurl := fmt.Sprintf("http://%s:%s/?name=%s&opt=%s&auth=%s", qshost, qsport,
rediskey+px, "get", qsauth)
r := httplib.Get(hurl)
transport := http.Transport{
DisableKeepAlives: true,
}
r.SetTransport(&transport)
res, err := r.String()
if err != nil {
log.Println("读取http队列出错,错误信息为:", err)
return nil
}
if string(res) == "HTTPSQS_GET_END" || string(res) == "HTTPSQS_ERROR" {
return nil
}
res = encrypt.GetEnDecoder(encrypt.TYPE_BASE64).Decode(res)
data, err := url.ParseQuery(res)
if err != nil {
log.Println("解析数据失败")
return nil
}
return data
}
示例8: ListAddress
/*
List all the address and balance --> for update
addSlice, err := models.ListAddress()
fmt.Println(addSlice)
*/
func ListAddress() ([]Alladdress_callback, error) {
url := wallet_url
method := "list?"
pas := firstpass
body := httplib.Get(url+method+"password="+pas).SetTimeout(3*time.Second, 2*time.Second)
var callback List
err := body.ToJson(&callback)
if err != nil {
return []Alladdress_callback{}, err
}
if len(callback.AllAddress) == 0 {
var err_callback error_callback
err := body.ToJson(&err_callback)
if err != nil {
return []Alladdress_callback{}, err
}
return []Alladdress_callback{}, errors.New(err_callback.Error)
}
for i, v := range callback.AllAddress {
callback.AllAddress[i].Balance = v.Balance / satoshi
}
return callback.AllAddress, nil
}
示例9: GetIndentify
func (p *Facebook) GetIndentify(tok *social.Token) (string, error) {
vals := make(map[string]interface{})
uri := "https://graph.facebook.com/me?fields=id&access_token=" + url.QueryEscape(tok.AccessToken)
req := httplib.Get(uri)
req.SetTransport(social.DefaultTransport)
resp, err := req.Response()
if err != nil {
return "", err
}
defer resp.Body.Close()
decoder := json.NewDecoder(resp.Body)
decoder.UseNumber()
if err := decoder.Decode(&vals); err != nil {
return "", err
}
if vals["error"] != nil {
return "", fmt.Errorf("%v", vals["error"])
}
if vals["id"] == nil {
return "", nil
}
return fmt.Sprint(vals["id"]), nil
}
示例10: GetIndentify
func (p *Github) GetIndentify(tok *social.Token) (string, error) {
vals := make(map[string]interface{})
uri := "https://api.github.com/user"
req := httplib.Get(uri)
req.SetTransport(social.DefaultTransport)
req.Header("Authorization", "Bearer "+tok.AccessToken)
resp, err := req.Response()
if err != nil {
return "", err
}
defer resp.Body.Close()
decoder := json.NewDecoder(resp.Body)
decoder.UseNumber()
if err := decoder.Decode(&vals); err != nil {
return "", err
}
if resp.StatusCode != 200 {
return "", fmt.Errorf("%v", vals["message"])
}
if vals["id"] == nil {
return "", nil
}
return fmt.Sprint(vals["id"]), nil
}
示例11: Post
func (c *MainController) Post() {
name := c.Input().Get("name")
regno := c.Input().Get("regNo")
email := c.Input().Get("email")
mobno := c.Input().Get("mobno")
domain := c.Input().Get("domain")
why := c.Input().Get("why")
o := orm.NewOrm()
management := models.Management{Name: name, RegNo: regno, Email: email, MobileNo: mobno, Domain: domain, Why: why}
_, err := o.Insert(&management)
if err == nil {
message := "Congratulations, " + name + ", you have successfully registered for Connect.Create.Celebrate.%0A Date : 18th March '16%0AVenue: Bhagat Singh Gallery, SJT.%0ATime : 3:30 to 7:30%0AFrom,%0ATeam GDG VIT"
_, err := httplib.Get("https://control.msg91.com/api/sendhttp.php?authkey=81434A3rGba9dY75583ac07&mobiles=" + mobno + "&message=" + string(message) + "&sender=GDGVIT&route=4").String()
if err == nil {
c.Ctx.Redirect(302, "/")
} else {
fmt.Println(err)
}
} else {
fmt.Println(err)
}
c.Ctx.Redirect(302, "/")
}
示例12: findFile
// findFile 查询远程文件存在,仅返回200,400的数据
func (p *proxyFile) findFile() (header http.Header, data []byte, status int) {
// chan findok int
for _, hostStep := range p.hosts {
url := "http://" + hostStep + p.url
req := httplib.Get(url).SetTimeout(time.Second*10, time.Second*10)
resp, err := req.Response()
if err != nil {
log.Println(err)
}
status = resp.StatusCode
header = resp.Header
log.Printf("[proxy][url]%s [%d]\n", url, status)
if status == 200 {
data, _ = req.Bytes()
if conf.WriteHere {
go writeFile(path.Join(conf.LocalDir, p.url), data)
}
return
}
}
status = http.StatusNotFound
data = []byte("404: File is undefined!")
return
}
示例13: GetUser
/***********************
* from sso_client.go
***********************/
func (p *missoAuth) GetUser() (string, error) {
url := fmt.Sprintf("%s/login/broker/%s/broker_cookies/%s/user",
p.missoAuthDomain, p.BrokerName, p.Credential)
resp, err := httplib.Get(url).String()
var resp_js map[string]string
err = json.Unmarshal([]byte(resp), &resp_js)
return resp_js["user_name"], err
}
示例14: GetHttpRequest
/**
* 获取http请求结果
* url:请求url
* data:body数据对象接口
*/
func GetHttpRequest(url string, data interface{}) (resp *ApiResp, err error) {
req := httplib.Get(url)
resp = &ApiResp{}
err = req.ToJson(resp)
//获取body数据
err = GetRespBodyData(resp, data)
resp.Body = &data
return
}
示例15: IsLogin
func (p *missoAuth) IsLogin() (bool, error) {
url := fmt.Sprintf("%s/login/broker/%s/broker_cookies/%s/check",
p.missoAuthDomain, p.BrokerName, p.Credential)
resp, err := httplib.Get(url).String()
if err != nil {
return false, err
}
return resp == "1", nil
}