public UserRetInfo ChooseClass(String username, String token, String ClassNum) { JObject postInfo = new JObject(); postInfo.Add(new JProperty("username", username)); postInfo.Add(new JProperty("token", token)); postInfo.Add(new JProperty("lesson_id", ClassNum)); var nvc = new Dictionary <String, String>(); foreach (var body in postInfo) { nvc.Add(body.Key, body.Value.ToString()); } String retInfo = Post("http://localhost:3000/api/select_lesson", nvc); if (retInfo.Length == 0) { return(null); } JObject retJson = JObject.Parse(retInfo); UserRetInfo result = new UserRetInfo(); result.Code = (int)retJson["code"]; result.Msg = (String)retJson["msg"]; return(result); }
public UserRetInfo Login(JObject json) { var nvc = new Dictionary <String, String>(); foreach (var body in json) { nvc.Add(body.Key, body.Value.ToString()); } var retInfo = Post("http://localhost:3000/api/login", nvc); if (retInfo.Length == 0) { return(null); } //String retInfo = "{\"code\": 0,\"msg\": \"成功\"}"; JObject retJson = JObject.Parse(retInfo); var result = new UserRetInfo(); result.Code = (int)retJson["code"]; result.Msg = (String)retJson["msg"]; if (result.Code == 0) { result.token = (String)retJson["token"]; } return(result); }