<?php function get_qq_group_list($qq, $skey, $p_skey) { // 计算bkn值 $bkn = bkn($skey); $url = 'https://qun.qq.com/cgi-bin/qun_mgr/get_group_list'; $cookie = "p_uin=o{$qq}; uin=o{$qq}; skey={$skey}; p_skey={$p_skey}"; $postData = "bkn={$bkn}"; $headers = [ "User-Agent: Mozilla/5.0 (Linux; Android 10; HLK-AL00 Build/HONORHLK-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.108 Safari/537.36 V1_AND_SQ_8.4.5_1468_YYB_D QQ/8.4.5.4745 NetType/4G WebP/0.4.1 Pixel/1080 StatusBarHeight/51 SimpleUISwitch/0 QQTheme/1000 InMagicWin/0", "Cookie: {$cookie}", "Referer: https://qun.qq.com/", "Content-Type: application/x-www-form-urlencoded", "Content-Length: " . strlen($postData) ]; $options = [ 'http' => [ 'method' => 'POST', 'header' => implode("\r\n", $headers), 'content' => $postData, 'timeout' => 30 ] ]; $context = stream_context_create($options); $response = file_get_contents($url, false, $context); return $response; } $qq = '123456'; $skey = '你的skey值'; $p_skey = '你的p_skey值'; $groupList = get_qq_group_list($qq, $skey, $p_skey); $groups = json_decode($groupList, true); echo "共获取到 " . count($groups['join']) . " 个群聊\n"; foreach ($groups['join'] as $group) { echo "群号: {$group['gc']}, 群名: {$group['gn']}\n"; } function bkn($skey) { $len = strlen($skey); $hash = 5381; for ($i = 0; $i < $len; $i++) { $hash += ($hash << 5 & 2147483647) + ord($skey[$i]) & 2147483647; $hash &= 2147483647; } return $hash & 2147483647; }