Skip to content
This repository has been archived by the owner on Jul 9, 2020. It is now read-only.

获取好友、群、讨论组列表 Api

ScienJus edited this page Dec 23, 2015 · 1 revision

获取群列表

请求方式:Post

请求 URL:http://s.web2.qq.com/api/get_group_name_list_mask2

Referer:http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2

请求参数只有一个r,值是一个 Json,内容为:

{
    "vfwebqq": "${vfwebqq}",
    "hash": "${hash}"
}

vfwebqq依旧是登录返回的参数,hashuinptwebqq进行加密后的数据,这里提供 Java 版本的加密算法:

private static String hash(long x, String K) {
    int[] N = new int[4];
    for (int T = 0; T < K.length(); T++) {
        N[T % 4] ^= K.charAt(T);
    }
    String[] U = {"EC", "OK"};
    long[] V = new long[4];
    V[0] = x >> 24 & 255 ^ U[0].charAt(0);
    V[1] = x >> 16 & 255 ^ U[0].charAt(1);
    V[2] = x >> 8 & 255 ^ U[1].charAt(0);
    V[3] = x & 255 ^ U[1].charAt(1);

    long[] U1 = new long[8];

    for (int T = 0; T < 8; T++) {
        U1[T] = T % 2 == 0 ? N[T >> 1] : V[T >> 1];
    }

    String[] N1 = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"};
    String V1 = "";
    for (long aU1 : U1) {
        V1 += N1[(int) ((aU1 >> 4) & 15)];
        V1 += N1[(int) (aU1 & 15)];
    }
    return V1;
}

请求成功后会返回一个 Json 对象,格式为:

{
    "retcode": 0,
    "result": {
        "gmasklist": [],
        "gnamelist": [
            {
                "flag": 167864331,
                "name": "群名",
                "gid": 14611812014,
                "code": 3157131718
            }
        ],
        "gmarklist": [
            {
                "uin": 18796074161,
                "markname": "备注"
            }
        ]
    }
}

retcode的值为0时说明此次请求是成功的。result中包含了3个 JsonArray:

  • gnamelist包含群信息,其中name为群名称,gid为群编号,codeflag暂时不知道有什么用。
  • gmarklist包含群的备注信息,uin为群编号,markname为备注名。
  • gmasklist暂时不知道有什么用。

获取好友列表

请求方式:Post

请求 http://s.web2.qq.com/api/get_user_friends2

Referer:http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1

请求参数和获取群列表一样。请求成功后会返回一个 Json 对象,格式为:

{
    "retcode": 0,
    "result": {
        "friends": [
            {
                "flag": 4,
                "uin": 41837138855,
                "categories": 1
            }
        ],
        "marknames": [
            {
                "uin": 37761915054,
                "markname": "备注",
                "type": 0
            }
        ],
        "categories": [
            {
                "index": 0,
                "sort": 2,
                "name": "同学"
            }
        ],
        "vipinfo": [
            {
                "vip_level": 0,
                "u": 20191343597,
                "is_vip": 0
            }
        ],
        "info": [
            {
                "face": 603,
                "flag": 4751942,
                "nick": "昵称",
                "uin": 41837138855
            }
        ]
    }
}

retcode的值为0时说明此次请求是成功的。result下有多个 JsonArray 对象:

  • frienduin为用户编号,categories为所属的分组编号。
  • marknamesuin为用户编号,markname为备注。
  • categoriesindex为组编号,name为组名,sort为排列顺序。
  • vipinfou为用户编号,is_vip为是否为会员,vip_level为会员等级。
  • infouin为用户编号,nick为用户的昵称。

获取讨论组列表

请求方式:Get

请求 URL:http://s.web2.qq.com/api/get_discus_list?clientid=53999199&psessionid=#{psessionid}&vfwebqq=#{vfwebqq}&t=0.1

Referer:http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2

Url 中有两个动态参数,都是登录后返回的数据,就不再重复了。

请求成功后会返回一个 Json 对象,格式为:

{
    "retcode": 0,
    "result": {
        "dnamelist": [
            {
                "did": 167864331,
                "name": "讨论组名",
            }
        ]
    }
}

retcode的值为0时说明此次请求是成功的。dnamelist为讨论组列表,其中did为讨论组编号,name为讨论组名称。

Clone this wiki locally