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

session_start();

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

// 飞书 OAuth 授权地址
$auth_url = 'https://open.feishu.cn/open-apis/authen/v1/authorize?' . http_build_query([
    'app_id' => FEISHU_APP_ID,
    'redirect_uri' => FEISHU_REDIRECT_URI,
    'state' => $state
]);

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