Files
saqel/public/api-test.html
T

93 lines
4.1 KiB
HTML

<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>فحص الـ API - منصة صقل</title>
<style>
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f4f7f6; margin: 0; padding: 20px; color: #333; }
h1, h2 { text-align: center; }
.card { background: white; padding: 20px; margin: 20px auto; max-width: 600px; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.form-group { margin-bottom: 15px; }
label { display: block; margin-bottom: 5px; font-weight: bold; }
input, select { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; }
button { background-color: #27ae60; color: white; border: none; padding: 10px 15px; cursor: pointer; border-radius: 4px; font-weight: bold; margin-bottom: 5px; }
button:hover { background-color: #2ecc71; }
pre { background: #2c3e50; color: #ecf0f1; padding: 15px; border-radius: 4px; overflow-x: auto; direction: ltr; text-align: left; max-height: 300px; }
.btn-info { background-color: #3498db; }
.btn-info:hover { background-color: #2980b9; }
.nav { text-align: center; margin-bottom: 20px; }
</style>
</head>
<body>
<div class="nav">
<a href="index.html">العودة للرئيسية</a>
</div>
<h1>أداة فحص الواجهات البرمجية (Pure PHP API Tester)</h1>
<div class="card">
<h2>فحص الاتصال والسرعة (Ping)</h2>
<button onclick="testPing()" class="btn-info">فحص /api/ping</button>
<h3>النتيجة:</h3>
<pre id="ping-result">في انتظار التنفيذ...</pre>
</div>
<div class="card">
<h2>تسجيل الدخول (Login)</h2>
<div class="form-group">
<label>البريد الإلكتروني:</label>
<input type="email" id="login-email" value="test@example.com">
</div>
<div class="form-group">
<label>كلمة المرور:</label>
<input type="password" id="login-password" value="secret">
</div>
<button onclick="testLogin()">تسجيل الدخول</button>
<h3>النتيجة:</h3>
<pre id="login-result">في انتظار التنفيذ...</pre>
</div>
<script>
async function testPing() {
const resultBox = document.getElementById('ping-result');
resultBox.innerHTML = 'جاري الاتصال بـ /index.php/api/ping...';
try {
// Notice we route through index.php since we haven't set up htaccess rewrite rules yet
const response = await fetch('/index.php/api/ping');
const data = await response.json();
resultBox.innerHTML = JSON.stringify(data, null, 2);
} catch (error) {
resultBox.innerHTML = 'خطأ في الاتصال: ' + error.message;
}
}
async function testLogin() {
const email = document.getElementById('login-email').value;
const password = document.getElementById('login-password').value;
const resultBox = document.getElementById('login-result');
resultBox.innerHTML = 'جاري الاتصال بـ /index.php/api/auth/login...';
try {
const response = await fetch('/index.php/api/auth/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({ email, password })
});
const data = await response.json();
resultBox.innerHTML = JSON.stringify(data, null, 2);
} catch (error) {
resultBox.innerHTML = 'خطأ في الاتصال: ' + error.message;
}
}
</script>
</body>
</html>