<?php
require_once dirname(__DIR__) . '/config.php';
require_once dirname(__DIR__) . '/includes/qq_config.php';

// 生成随机 state 防止 CSRF
$state = bin2hex(random_bytes(16));
$_SESSION['qq_state'] = $state;

// QQ 授权地址
$auth_url = 'https://graph.qq.com/oauth2.0/authorize?' . http_build_query([
    'response_type' => 'code',
    'client_id' => QQ_APP_ID,
    'redirect_uri' => QQ_REDIRECT_URI,
    'state' => $state,
    'scope' => 'get_user_info'
]);

header('Location: ' . $auth_url);
exit;