<!DOCTYPE html>
<html>
<head>
    <title>Chat API Test</title>
    <style>
        body { font-family: Arial; padding: 20px; background: #f5f5f5; }
        .test { background: white; padding: 15px; margin: 10px 0; border-radius: 5px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
        .success { color: green; font-weight: bold; }
        .error { color: red; font-weight: bold; }
        .warning { color: orange; font-weight: bold; }
        pre { background: #f0f0f0; padding: 10px; border-radius: 3px; overflow: auto; }
        h2 { color: #333; }
    </style>
</head>
<body>
    <h1>🔍 Testing Chat API Endpoints</h1>
    <p>Server Time: 2026-06-13 08:57:16</p>

<div class='test'><h2>Test 1: Basic API Connection</h2>HTTP Code: 200<br><span class='success'>✅ API is reachable</span><br>Response: {&quot;success&quot;:true,&quot;message&quot;:&quot;Sync API is working&quot;,&quot;data&quot;:{&quot;version&quot;:&quot;1.0&quot;,&quot;timestamp&quot;:&quot;2026-06-13 08:57:17&quot;,&quot;server&quot;:&quot;Apache&quot;,&quot;php_version&quot;:&quot;8.3.31&quot;,&quot;database&quot;:&quot;ace4eso3_farmpro&quot;}}<br></div><div class='test'><h2>Test 2: Configuration Check</h2>API_KEY defined: ✅ Yes<br>DB_HOST: localhost<br>DB_NAME: nscswuim_farmproncb<br>API_KEY length: 32 characters<br></div><div class='test'><h2>Test 3: Database Connection</h2><span class='success'>✅ Database connection successful</span><br><br>Checking required tables:<br><span class='success'>✅ Table 'chats' exists</span><br><span class='success'>✅ Table 'chat_participants' exists</span><br><span class='success'>✅ Table 'messages' exists</span><br><span class='success'>✅ Table 'message_receipts' exists</span><br><span class='success'>✅ Table 'message_reactions' exists</span><br></div><div class='test'><h2>Test 4: Get Users</h2>HTTP Code: 200<br><span class='success'>✅ Get users endpoint working</span><br>Found 12 users in database<br></div><div class='test'><h2>Test 5: Get Chats</h2>HTTP Code: 200<br><span class='success'>✅ Get chats endpoint working</span><br>Found 0 chats for user 1<br></div><div class='test'><h2>Test 6: Upload Directory</h2><span class='success'>✅ Upload directory exists</span><br>Path: /home/nscswuim/ncb.farmproapps.com/farm_sync/chat_uploads/<br>Writable: ✅ Yes<br><span class='success'>✅ Subdirectory 'images' exists</span><br><span class='success'>✅ Subdirectory 'videos' exists</span><br><span class='success'>✅ Subdirectory 'voice' exists</span><br><span class='success'>✅ Subdirectory 'documents' exists</span><br><span class='success'>✅ Subdirectory 'thumbnails' exists</span><br></div><div class='test'><h2>Test 7: API Key Validation</h2>Valid key response: 200<br>Invalid key response: 200<br><span class='error'>❌ API key validation issue - valid key should return 200, invalid should return 401</span><br></div><div class='test'><h2>📝 Summary</h2><p><strong>API URL:</strong> https://agrigrowthafrica.org/farm_sync/sync.php</p><p><strong>API Key:</strong> UVT8i@b$C<... (length: 32)</p><p><strong>Database:</strong> nscswuim_farmproncb</p><p>If all tests passed with green checks, your chat API is ready to use!</p><p>Next steps:</p><ol><li>In your app Settings, enter the chat URL: <strong>https://agrigrowthafrica.org/farm_sync/sync.php</strong></li><li>Enter the API key: <strong>UVT8i@b$C&lt;]hz0&amp;E#oWs|)FA8VzGU3bN</strong></li><li>Click 'Test Connection' in the app - should show success</li><li>Start chatting!</li></ol></div></body>
</html>
