curl --request GET \
--url https://api.example.com/api/check-updates.php{
"success": true,
"has_update": true,
"has_updates": true,
"conversation_id": "<string>",
"updated_conversations": [
{
"id": "<string>",
"last_message_at": "<string>",
"status": "<string>"
}
],
"server_time": "<string>",
"status": "<string>",
"can_enable_ai": true
}Poll for real-time updates to conversations and messages
curl --request GET \
--url https://api.example.com/api/check-updates.php{
"success": true,
"has_update": true,
"has_updates": true,
"conversation_id": "<string>",
"updated_conversations": [
{
"id": "<string>",
"last_message_at": "<string>",
"status": "<string>"
}
],
"server_time": "<string>",
"status": "<string>",
"can_enable_ai": true
}GET /api/check-updates.php
Y-m-d H:i:s formatY-m-d H:i:s formatcurl "https://yourdomain.com/api/check-updates.php?last_check=2024-03-06%2010:30:00&conversation_id=123"
{
"success": true,
"has_update": false,
"conversation_id": "123",
"server_time": "2024-03-06 10:35:00"
}
GET /api/check-conversation-updates.php
Y-m-d H:i:s format{
"success": true,
"has_updates": true,
"updated_conversations": [
{
"id": "123",
"last_message_at": "2024-03-06 10:34:22",
"status": "active"
},
{
"id": "456",
"last_message_at": "2024-03-06 10:33:15",
"status": "active"
}
],
"server_time": "2024-03-06 10:35:00"
}
GET /api/check-openai-status.php
active: Service is operationalinsufficient_funds: Account has insufficient funds{
"success": true,
"status": "active",
"can_enable_ai": true
}
let lastCheck = new Date().toISOString().slice(0, 19).replace('T', ' ');
setInterval(async () => {
const response = await fetch(
`/api/check-updates.php?last_check=${encodeURIComponent(lastCheck)}`
);
const data = await response.json();
if (data.has_updates) {
// Fetch updated conversations
data.updated_conversations.forEach(id => {
fetchConversationMessages(id);
});
}
// Update timestamp for next poll
lastCheck = data.server_time;
}, 3000);
server_time from responses for the next last_checklast_check gracefully (returns no updates)