'CaPaCaptain', // 从截图中的仓库访问看到 'repo' => 'VvvebJs_huggingface_db_01', // 从截图中看到 'branch' => 'main', 'path' => 'pages/', 'token' => $_ENV['GITHUB_TOKEN'] ?? getenv('GITHUB_TOKEN') ?: '' ]; function testGitHubAPI($url, $token, $method = 'GET', $data = null) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_TIMEOUT, 15); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: token ' . $token, 'User-Agent: VvvebJs-TokenTest/1.0', 'Accept: application/vnd.github.v3+json', 'Content-Type: application/json' ]); if ($data) { curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); } $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $error = curl_error($ch); curl_close($ch); return [ 'success' => $httpCode >= 200 && $httpCode < 300, 'code' => $httpCode, 'response' => $response, 'error' => $error ]; } $results = []; if ($_POST['test'] ?? false) { // 测试 1: Token 有效性 $results['token'] = testGitHubAPI('https://api.github.com/user', $config['token']); // 测试 2: 仓库访问 $repoUrl = "https://api.github.com/repos/{$config['owner']}/{$config['repo']}"; $results['repo'] = testGitHubAPI($repoUrl, $config['token']); // 测试 3: 分支检查 $branchUrl = "https://api.github.com/repos/{$config['owner']}/{$config['repo']}/branches/{$config['branch']}"; $results['branch'] = testGitHubAPI($branchUrl, $config['token']); // 测试 4: 写入权限测试 $testFile = 'token-test-' . date('Y-m-d-H-i-s') . '.html'; $testContent = 'Token Test

GitHub Token 测试

创建时间: ' . date('Y-m-d H:i:s') . '

'; $createUrl = "https://api.github.com/repos/{$config['owner']}/{$config['repo']}/contents/{$config['path']}{$testFile}"; $results['write'] = testGitHubAPI($createUrl, $config['token'], 'PUT', [ 'message' => 'VvvebJs Token 测试文件', 'content' => base64_encode($testContent), 'branch' => $config['branch'] ]); } ?> 当前 GitHub Token 测试

🔑 当前 GitHub Token 配置测试

📋 从截图推断的配置

GitHub Owner:

Repository:

Token 状态:

Branch:

Path:

完整 URL:
https://github.com//

🔬 测试结果

1. Token 验证
结果: (HTTP )
当前用户:
用户名:
用户类型:
2. 仓库访问测试
结果: (HTTP )
仓库全名:
私有仓库:
默认分支:
权限: - Admin: - Push: - Pull:
3. 分支检查
结果: (HTTP )
分支名:
最新提交:
提示: 分支 "" 不存在。可能需要使用 "master" 分支。
4. 文件写入权限测试
结果: (HTTP )
🎉 恭喜!Token 配置完全正确,可以正常保存文件到 GitHub。
您可以开始使用 VvvebJs 编辑器了!
错误详情:

⚙️ 推荐的环境变量配置

在您的 Hugging Face Space Settings 中设置以下环境变量:

GITHUB_TOKEN=your_token_here
GITHUB_OWNER=
GITHUB_REPO=
GITHUB_BRANCH=
GITHUB_PATH=
STORAGE_TYPE=github
⚠️ 注意: 检测到分支 "main" 不存在,建议使用 "master" 分支。
❌ GitHub Token 未配置

请在环境变量中设置 GITHUB_TOKEN

Token 应该是您在 GitHub 截图中创建的那个。