private string GetBeijingTime()
{
///获得标准的北京时间;
///
// Creates an HttpWebRequest with the specified URL.
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create("http://api.k780.com/?app=life.time&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json"); //构建http request
// Sends the HttpWebRequest and waits for the response.
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
// Gets the stream associated with the response.
Stream receiveStream = myHttpWebResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
// Pipes the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader(receiveStream, encode);
Char[] read = new Char[256];
// Reads 256 characters at a time.
int count = readStream.Read(read, 0, 256);
while (count > 0)
{
// Dumps the 256 characters on a string and displays the string to the console.
String strnow = new String(read, 0, count);
count = readStream.Read(read, 0, 256);
JObject jo = (JObject)JsonConvert.DeserializeObject(strnow);
if (jo.ToString() != null)
{
string zone = jo["result"]["datetime_1"].ToString();
//lb_DBWrite_DAY.Visible = true;
//lb_DBWrite_DAY.Text = zone;
BeijingTime = zone;
}
}
TH.SetRichTextBoxADD(rtxtServerMsgList, BeijingTime + "\r\n");
// Releases the resources of the response.
myHttpWebResponse.Close();
// Releases the resources of the Stream.
return BeijingTime;
}