func (c Connection) ApiTest() revel.Result { test := make(map[string]interface{}) test["a"] = "1" test["b"] = 2 RequestData := api.CreateRequestData(test) revel.INFO.Println("RequestData:%+v", RequestData) revel.INFO.Println("json :%#v", RequestData.ToJSON()) return c.RenderTemplate("debug.html") }
func (c Connection) ApiToServer() revel.Result { httpclient.Defaults(httpclient.Map{ "opt_timeout": TIMEOUT, }) httpclient.WithHeader("Content-Type", "text/html;charset=utf-8") body := make(map[string]interface{}) body["id"] = "1465825473352" body["encrypt"] = "md5" body["sign"] = "588c125e2e665907e47e55297de2d20e" client := make(map[string]interface{}) client["caller"] = "guild.website" client["ex"] = "" body["client"] = client data := make(map[string]interface{}) data["uid"] = 49991 body["data"] = data bodyJSON, err := json.Marshal(body) if err != nil { panic(err) } println(string(bodyJSON)) res, _ := httpclient.PostString("http://127.0.0.1:9151/ucgc/girl/recommend", string(bodyJSON)) fmt.Println("Response:") fmt.Println(res.ToString()) test := make(map[string]interface{}) test["a"] = "1" test["b"] = 2 RequestData := api.CreateRequestData(test) fmt.Println(RequestData) return c.RenderTemplate("debug.html") }