获取QQ当前状态

    ///
    /// 获取QQ当前状态(1:在线,0:不在线,-1:不存在)
    ///

    /// qq号
    ///
    public static int GetQQState(long qq)
    {
        WebClient client = new WebClient();
        byte[] data;
        try { data = client.DownloadData("http://wpa.qq.com/pa?p=1:" + qq.ToString() + ":1"); }
        catch { data = new byte[0]; }
        switch (data.Length)
        {
            case 2329:
                return 1;
                break;
            case 2262:
                return 0;
                break;
            case 0:
                return -1;
                break;
            default:
                return -1;
                break;
        }

    }


作者:朱会震


你可能感兴趣的:(C#.NET,技术)