C#.NET判断qq在线状态 - 是否在线

 
// 方法
using System.Net;
using System;
public class QQUtility
{
  
public static bool IsOnline( string qq)
  {
    
// 312124752
     string url = string .Format( " http://wpa.qq.com/pa?p=1:{0}:3 " ,qq);
    HttpWebRequest request
= (HttpWebRequest)WebRequest.Create(url);
    request.Headers.Set(
" Pragma " , " no-cache " );
    HttpWebResponse HttpWResp
= (HttpWebResponse)request.GetResponse();
    
string query = HttpWResp.ResponseUri.PathAndQuery;
    
switch (query)
    {
      
case " /rtx_offline.gif " :
        
return false ;
      
case " /rtx_online.gif " :
        
return true ;
      
default :
        
return true ;
    }
  }
}

// 调用:
QQUtility.IsOnline( " 312124752 " ));

你可能感兴趣的:(qq,String,url,Class,query)