12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Text;
- namespace Winsoft.GOV.Auth.Demo
- {
- class Program
- {
- static void Main(string[] args)
- {
- PostMethd();
- Console.ReadKey();
- }
- public static void PostMethd()
- {
- HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://www.lszszw.gov.cn/OAuth/api/Message");
- Encoding encoding = Encoding.UTF8;
- string param = "{\"OpenId\":\"oIeaexOZUPG-953Ci3wsjy_KReDU\",\"Content\":\"hello world\"}";
- byte[] bs = Encoding.UTF8.GetBytes(param.ToString());
- //byte[] bs = new byte[]{};
- string responseData = String.Empty;
- req.Method = "POST";
-
- req.ContentType = "application/json;charset=utf-8";
- req.ContentLength = bs.Length;
- //return;
- using (Stream reqStream = req.GetRequestStream())
- {
- reqStream.Write(bs, 0, bs.Length);
- reqStream.Close();
- }
-
- using (HttpWebResponse response = (HttpWebResponse)req.GetResponse())
- {
- Console.WriteLine(response.StatusCode);
- }
- }
- }
- }
|