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

$config = getLhouathConfig();

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

header('Location: https://open.lhwks.cn/authorize.php?' . http_build_query([
    'response_type' => 'code',
    'client_id'     => $config['app_id'],
    'redirect_uri'  => $config['redirect_uri'],
    'state'         => $state,
]));
exit;