示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string strId = textUserId.Text;
            string strName = textTitle.Text;

            ASCIIEncoding encoding = new ASCIIEncoding();
            string postData = "user_id=" + strId;
            postData += ("&title=" + strName);
            MyWebRequest My = new MyWebRequest("http://zozatree.herokuapp.com/api/titles", "POST", postData);
            string HtmlResult = My.GetResponse();
            //wc.Headers["Content-type"] = "application/x-www-form-urlencoded";

            //string HtmlResult = wc.UploadString(URL, myParamters);

            string bodySeparator = "{";
            string[] stringSeparators = new string[] { bodySeparator };
            string[] splitBodey = HtmlResult.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries);
            List<UserBO> u = new List<UserBO>();
            foreach (string item in splitBodey)
            {
                UserBO b = new UserBO(item.Replace("}",""));
                u.Add(b);
                if (b.UserId != -1)
                    labResponse.Text += b.toString();
            }
        }
示例#2
0
        private void button2_Click(object sender, EventArgs e)
        {
            string GetData = "user_id=" + textGetUserId.Text;
            MyWebRequest My = new MyWebRequest("http://zozatree.herokuapp.com/api/titles?" + GetData, "GET");

            string HtmlResult = My.GetResponse();

            string bodySeparator = "{";
            string[] stringSeparators = new string[] { bodySeparator };
            string[] splitBodey = HtmlResult.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries);
            List<UserBO> u = new List<UserBO>();
            foreach (string item in splitBodey)
            {
                UserBO b = new UserBO(item.Replace("}", ""));
                u.Add(b);
                if(b.UserId!=-1)
                textGetResolt.Text += b.toString()+'\n';
            }
        }
示例#3
0
        private void respones_btn_Click(object sender, EventArgs e)
        {
            string url, data;

            url  = textBox1.Text;
            data = textBox2.Text;

            if (get.Checked)
            {
                MyWebRequest myRequest = new MyWebRequest(url, "GET");
                result.Text = myRequest.GetResponse();
            }


            else if (post.Checked)
            {
                MyWebRequest myRequest = new MyWebRequest(url, "POST", data);
                result.Text = "";
            }
        }