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

// 设置绑定模式
$_SESSION['qq_bind'] = true;
$_SESSION['qq_bind_user_id'] = $_SESSION['user_id'];

$state = bin2hex(random_bytes(16));
$_SESSION['qq_state'] = $state;

$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;