C # obtain QQ online status code

Source: Internet
Author: User

Query statement of QQ number query result
21117217 gif89aj http://wpa.qq.com/pa? P = 1: 1: 21117217: 3
195651222 gif89ak http://wpa.qq.com/pa? P = 1: 1: 252520115: 3
426002343 gif89aj http://wpa.qq.com/pa? P = 1: 1: 4366727: 3

/// Add reference

Using system. IO;
Using system. net;
Using system. text;

// Button event

Private void button3_click (Object sender, system. eventargs E)
{

If (textbox3.text = "")
{
MessageBox. Show ("the QQ number of the current query is required! "," Error message! ");
Textbox3.focus ();
Return;
}
Else
{
String strqq = textbox3.text. Trim ();
String strsearchqq = "http://wpa.qq.com/pa? P = 1: "+ strqq +": 3 ";
String strqqstatus = getwebcontent (strsearchqq). substring (0, 7 );
Switch (strqqstatus)
{
Case "gif89ak": MessageBox. Show (strqq + "not online", "QQ status prompt! ");
Break;
Case "gif89aj": MessageBox. Show (strqq + "not online", "QQ status prompt! ");
Break;
}
}
}

// Call a function

// Obtain the HTML source code of the webpage based on the URL
Private string getwebcontent (string URL)
{
String strresult = "";
Try
{
Httpwebrequest request = (httpwebrequest) webrequest. Create (URL );
// Declare an httpwebrequest request
Request. Timeout = 30000;
// Set the connection timeout
Request. headers. Set ("Pragma", "No-Cache ");
Httpwebresponse response = (httpwebresponse) request. getresponse ();
Stream streamreceive = response. getresponsestream ();
Encoding encoding = encoding. getencoding ("gb2312 ");
Streamreader = new streamreader (streamreceive, encoding );
Strresult = streamreader. readtoend ();
}
Catch
{
MessageBox. Show ("error ");
}
Return strresult;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.