'https://auth.naixi.net', 'client_id' => '6c597d1551b868dce9fe', 'client_secret' => '065b759106ce704cb49082b9ebc790266f4e7105' ]; // cURL 函数 function get_curl($url, $post = 0, $referer = 0, $cookie = 0, $header = 0, $ua = 0, $nobaody = 0, $addheader = 0) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); $httpheader[] = "Accept: */*"; $httpheader[] = "Accept-Encoding: gzip,deflate,sdch"; $httpheader[] = "Accept-Language: zh-CN,zh;q=0.8"; $httpheader[] = "Connection: close"; if ($header) { $httpheader = array_merge($httpheader, $header); } curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader); if ($post) { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); } if ($header) { curl_setopt($ch, CURLOPT_HEADER, false); } if ($cookie) { curl_setopt($ch, CURLOPT_COOKIE, $cookie); } if ($referer) { if ($referer == 1) { curl_setopt($ch, CURLOPT_REFERER, ''); } else { curl_setopt($ch, CURLOPT_REFERER, $referer); } } if ($ua) { curl_setopt($ch, CURLOPT_USERAGENT, $ua); } else { curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"); } if ($nobaody) { curl_setopt($ch, CURLOPT_NOBODY, 1); } curl_setopt($ch, CURLOPT_ENCODING, "gzip"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $ret = curl_exec($ch); curl_close($ch); return $ret; } $code = $_GET['code']; $header = []; $post = http_build_query([ 'grant_type' => 'authorization_code', 'code' => $code, "client_id"=> $_LINUXDO_CONNECT["client_id"], "client_secret"=> $_LINUXDO_CONNECT["client_secret"], ]); $getTokenRes = get_curl($_LINUXDO_CONNECT["base"].'/api/login/oauth/access_token', $post, 0, 0, $header); $getTokenArr = json_decode($getTokenRes, true); if (isset($getTokenArr['access_token'])) { $access_token = $getTokenArr['access_token']; $header = [ 'Authorization: Bearer ' . $access_token ]; $getUserRes = get_curl($_LINUXDO_CONNECT["base"].'/api/userinfo', 0, 0, 0, $header); $getUserArr = json_decode($getUserRes, true); } else { $err = json_encode($getTokenArr); } ?> <?= $_CONFIG['game_name'] ?> <?= $_CONFIG['game_description'] ?> 授权发生异常: