func GetUserInfo(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { user_name := r.FormValue("user_name") token := r.FormValue("token") fmt.Println("user_name=", user_name) fmt.Println("token=", token) strCheckURL := "https://connect.funzhou.cn/oauth2/privilige" strInterface := "get_user_info" value := url.Values{} value.Set("token", token) value.Set("privilige", strInterface) strBody, err := common.Invoker(common.HTTP_POST, strCheckURL, value) if err != nil { fmt.Println(err) strBody, _ := setParams("/auth/get_user_info", 1, "submit check faild !", "") w.Write(strBody) return } fmt.Println(strBody) var result AUResponse err = json.Unmarshal([]byte(strBody), &result) if err != nil { strBody, _ := setParams("/auth/get_user_info", 1, "json data decode faild!", "") w.Write(strBody) return } if result.Code != 0 { strBody, _ := setParams("/auth/get_user_info", 1, "user check faild beacuse of "+result.Message, "") w.Write(strBody) return } session := common.GetSession() if session == nil { strBody, _ := setParams("/auth/get_user_info", 1, "get DB faild !!", "") w.Write(strBody) return } defer common.FreeSession(session) user_info := Account{} coll := session.DB("at_db").C("user_tab") condition_or := bson.M{"$or": []bson.M{bson.M{"user_name": user_name}, bson.M{"email": user_name}, bson.M{"mobile": user_name}}} coll.Find(condition_or).Sort(user_name).One(&user_info) strResult, err := json.Marshal(user_info) if err != nil { strBody, _ := setParams("/auth/get_user_info", 1, "json data encode faild!", "") w.Write(strBody) return } strResult, _ = setParams("/auth/get_user_info", 0, "ok", string(strResult)) w.Write(strResult) return }
func main() { value := url.Values{"token": {"0rBIXKgoRnWv7XntfV0JCg"}, "user_name": {"tomzhao"}} strBody, err := common.Invoker(common.HTTP_POST, "http://127.0.0.1:8090/auth/get_user_info", value) if err != nil { fmt.Println(err) return } fmt.Println(strBody) return /* //strClient:="{\"Id\":\"1234\",\"Secret\":\"aabbccdd\",\"RedirectUri\":\"http://localhost:8080\",\"UserData\":\"\"}" var client Client client.Id="1234" client.Secret="aabbccdd" client.RedirectUri="http://localhost:8080" client.UserData="" strTem:=toJSON(client) fmt.Println("strTem=", strTem) var client_test Client strClient:="{\"Id\":\"1234\",\"Secret\":\"aabbccdd\",\"RedirectUri\":\"http://localhost:8080\",\"UserData\":\"\"}" fmt.Println("strClient=", strClient) fromJSON(strClient,&client_test) fmt.Println(client_test) //strImage,strTag:=GetImage("10.122.75.228:5000/centostest:latest") //fmt.Println("strImage=", strImage) //fmt.Println("strTag=", strTag) //return */ //httpGet() //httpPost() //httpPostForm() //httpDo() }
func main() { /* var Url *url.URL Url, err := url.Parse("http://sms.gyjbh.nvwayun.com") if err != nil { panic("boom") } mesaage:=make(map[string]string) mesaage["mobile"]="18585816540" mesaage["msg"]="888888(动态验证码),请在5分钟内输入该验证码." strData, err := json.Marshal(mesaage) if err != nil { return } Url.Path += "/application/api" strTnterfaceKey:="ad79bd61-4cc8-f4a4-2811-55e0117e6cc4" strInterfaceSign:="4bf38c7e184df4087910038afc7df8b9b899aa2f" strSend:=base64.StdEncoding.EncodeToString(strData) parameters := url.Values{} parameters.Add("data", strSend) parameters.Add("interface_key", strTnterfaceKey) parameters.Add("interface_sign", strInterfaceSign) Url.RawQuery = parameters.Encode() fmt.Printf("Encoded URL is %q\n", Url.String()) strResult,err:=common.Invoker(common.HTTP_GET,Url.String(),"") if err!=nil { return } fmt.Println(strResult) //lue:=url.Values{"data_type":{"1"},"start_time": {"1439395200"},"end_time":{"1439740800"}} value:=url.Values{"data_type":{"1"},"start_time": {"1441078590"},"end_time":{"1441078590"}} strBody,err:=common.Invoker(common.HTTP_POST,"https://connect.funzhou.cn/manage/export_data",value) if err!=nil { fmt.Println(err) return } fmt.Println(strBody) strVerifyCode:="912297" value:=url.Values{"mobile": {"18585816540"},"verify_code":{strVerifyCode},"show_id":{"tomtest"}} //value:=url.Values{"mobile": {"15519028660"},"verify_code":{strVerifyCode}} //value:=url.Values{"mobile": {"18585816540"},"verify_code":{strVerifyCode}} //value:=url.Values{"mobile": {"18984550575"},"verify_code":{strVerifyCode}} //value:=url.Values{"mobile": {"18585816540"},"verify_code":{strVerifyCode}} strBody,err:=common.Invoker(common.HTTP_POST,"https://connect.funzhou.cn/user/get_verify_code",value) //strBody,err:=common.Invoker(common.HTTP_POST,"https://connect.funzhou.cn/user/check_verify_code",value) if err!=nil { fmt.Println(err) return } fmt.Println(strBody) value:=url.Values{"openid": {"55e170e1e138230f4zhw"}} //value:=url.Values{"id": {"55cabc1de1382334ec000006"},"need_send_sms":{"0"}} //value:=url.Values{"id": {"55e14babe138232c79000001"}} //value:=url.Values{"mobile": {"18585816666"}} //value:=url.Values{"company": {"infobird1"}} strBody,err:=common.Invoker(common.HTTP_POST,"https://connect.funzhou.cn/user/get_user_info",value) if err!=nil { fmt.Println(err) return } var result Response json.Unmarshal([]byte(strBody),&result) fmt.Println(result) fmt.Println(strBody) //password:=common.MD5("111111") //value:=url.Values{"acname":{"18585816540"},"password":{password},"show_id":{"tomtest"},"name": {"tomzhao"},"company_name": {"infobird"},"job":{"yanfa"},"company_addr":{""},"email":{"*****@*****.**"},"mobile":{"18585816540"}} //value:=url.Values{"acname":{"18984550006"},"password":{password},"name": {"zhanghuawen"},"source_id": {"funzhou_0001"},"company_name": {"infobird"},"job":{"yanfa"},"company_addr":{""},"email":{"*****@*****.**"},"mobile":{"18984550006"}} //value:=url.Values{"name": {"zhanghuawen"},"source_id": {"funzhou_0001"},"company_name": {"infobird"},"job":{"yanfa"},"company_addr":{""},"email":{"*****@*****.**"},"mobile":{"18984550006"}} //value:=url.Values{"reg_type":{"1"},"show_id":{"tomtest"},"name": {"zhanghuawen"},"source_id": {"funzhou_0001"},"company_name": {"infobird"},"job":{"yanfa"},"haha11":{"yanfa"},"company_addr":{""},"email":{"*****@*****.**"},"mobile":{"18984550008"}} value:=url.Values{"reg_type":{"1"},"show_id":{"tomtest"},"name": {"tomzhao"},"company_name": {"infobird"},"job":{"yanfa"},"company_addr":{""},"email":{"*****@*****.**"},"mobile":{"18585816540"}} strBody,err:=common.Invoker(common.HTTP_POST,"https://connect.funzhou.cn/user/register",value) if err!=nil { fmt.Println(err) return } fmt.Println(strBody) // "email": "*****@*****.**", value:=url.Values{"mobile": {"18984550575"}} strBody,err:=common.Invoker(common.HTTP_POST,"https://connect.funzhou.cn/user/exist",value) if err!=nil { fmt.Println(err) return } fmt.Println(strBody) password:=common.MD5("123456") new_password:=common.MD5("123456") value:=url.Values{"acname": {"*****@*****.**"},"password":{password},"new_password":{new_password}} //strBody,err:=common.Invoker(common.HTTP_POST,"https://connect.funzhou.cn/user/register",value) //strBody,err:=common.Invoker(common.HTTP_POST,"https://connect.funzhou.cn/user/change_password",value) strBody,err:=common.Invoker(common.HTTP_POST,"https://connect.funzhou.cn/manage/reset_password",value) if err!=nil { fmt.Println(err) return } fmt.Println(strBody) value:=url.Values{"fieldes": {"qq,email,mobile,weibo,openid"}} strBody,err:=common.Invoker(common.HTTP_GET,"https://connect.funzhou.cn/manage/get_only_check_list",value) //strBody,err:=common.Invoker(common.HTTP_POST,"https://connect.funzhou.cn/manage/update_only_check_list",value) if err!=nil { fmt.Println(err) return } fmt.Println(strBody) password:=common.MD5("33335") value:=url.Values{"acname": {"*****@*****.**"},"password":{password}} strBody,err:=common.Invoker(common.HTTP_POST,"https://connect.funzhou.cn/user/login",value) if err!=nil { fmt.Println(err) return } fmt.Println(strBody) //value:=url.Values{"id": {"55cc4cc6e138237243000054"},"show_id":{"tomtest"},"name": {"zhanghuawen"},"source_id": {"funzhou_0001"},"company_name": {"infobird"},"job":{"yanfa"},"haha":{"yanfa66"},"company_addr":{""},"email":{"*****@*****.**"},"mobile":{"18984550008"}} value:=url.Values{"id": {"55cc4cc6e138237243000054"},"show_id":{"tomtest"},"name": {"tomzhao"},"company_name": {"infobird"},"job":{"yanfa"},"company_addr":{""},"email":{"*****@*****.**"},"mobile":{"18585816540"}} strBody,err:=common.Invoker(common.HTTP_POST,"https://connect.funzhou.cn/user/set_user_info",value) if err!=nil { fmt.Println(err) return } fmt.Println(strBody) value:=url.Values{"id": {"55cc4cc6e138237243000054"},"show_id":{"tomtest"}} //value:=url.Values{"id": {"55cc4cc6e138237243000054"}} //value:=url.Values{"mobile": {"18585816540"},"show_id":{"tomtest"}} //value:=url.Values{"mobile": {"18585816540"}} strBody,err:=common.Invoker(common.HTTP_POST,"https://connect.funzhou.cn/user/get_user_info",value) if err!=nil { fmt.Println(err) return } fmt.Println(strBody) //value:=url.Values{"start_time": {"1441728000"},"end_time": {"1441814400"}} //value:=url.Values{"start_time": {"1441814400"},"end_time": {"1441900800"}} //value:=url.Values{"start_time": {"1441900800"},"end_time": {"1441987200"}} //value:=url.Values{"start_time": {"1441987200"},"end_time": {"1442073600"}} value:=url.Values{"data_type": {"1"},"start_time": {"1441728000"},"end_time": {"1442073600"}} //strBody,err:=common.Invoker(common.HTTP_POST,"https://connect.funzhou.cn/manage/user_stat",value) strBody,err:=common.Invoker(common.HTTP_POST,"https://connect.funzhou.cn/manage/export_data",value) if err!=nil { fmt.Println(err) return } fmt.Println(strBody) */ value := url.Values{"user_list": {"5618756de138232ed4000d2c,55cc4cc6e138237243000054"}, "show_id": {"tomtest"}} strBody, err := common.Invoker(common.HTTP_POST, "https://connect.funzhou.cn/user/get_user_list", value) if err != nil { fmt.Println(err) return } fmt.Println(strBody) }