Files
sam-kd/ocr/test_api.php

30 lines
895 B
PHP
Raw Permalink Normal View History

<?php
// 간단한 API 연결 테스트
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
// 권한 체크
if ($level > 5) {
die(json_encode(['ok' => false, 'error' => '접근 권한이 없습니다.']));
}
// API 키 읽기
$apiKeyFile = $_SERVER['DOCUMENT_ROOT'] . '/apikey/claude_api.txt';
$response = [
'file_exists' => file_exists($apiKeyFile),
'file_path' => $apiKeyFile,
'document_root' => $_SERVER['DOCUMENT_ROOT']
];
if (file_exists($apiKeyFile)) {
$apiKey = trim(file_get_contents($apiKeyFile));
$response['key_length'] = strlen($apiKey);
$response['key_prefix'] = substr($apiKey, 0, 20) . '...';
$response['key_valid_format'] = (strpos($apiKey, 'sk-ant-api') === 0);
} else {
$response['error'] = 'API 키 파일을 찾을 수 없습니다.';
}
header('Content-Type: application/json');
echo json_encode($response, JSON_PRETTY_PRINT);