1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| <?php
header('Access-Control-Allow-Origin:*');
$qq = $_GET['qq'] ?? null; if (!$qq || !is_numeric($qq)) { sendResponse(201, '提供的QQ号码无效。'); exit; }
$agent = strtolower($_SERVER['HTTP_USER_AGENT']); $is_pc = strpos($agent, 'windows nt') !== false; $is_iphone = strpos($agent, 'iphone') !== false; $is_ipad = strpos($agent, 'ipad') !== false; $is_android = strpos($agent, 'android') !== false;
$urls = [ 'pc' => "tencent://Message/?uin=$qq", 'iphone' => "mqq://im/chat?chat_type=wpa&uin=$qq&version=1&src_type=web", 'ipad' => "mqq://im/chat?chat_type=wpa&uin=$qq&version=1&src_type=web", 'android' => "mqqwpa://im/chat?chat_type=wpa&uin=$qq" ];
if ($is_pc) { header("Location: " . $urls['pc']); } elseif ($is_iphone) { header("Location: " . $urls['iphone']); } elseif ($is_ipad) { header("Location: " . $urls['ipad']); } elseif ($is_android) { header("Location: " . $urls['android']); } else { sendResponse(201, '不支持的设备类型。'); }
function sendResponse($code, $message) { echo json_encode(['code' => $code, 'message' => $message], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); exit; }
|