diff --git a/api.php b/api.php index e50cd0c..6020685 100644 --- a/api.php +++ b/api.php @@ -776,6 +776,43 @@ try { } break; + case 'mark_post_published': + $scheduledFile = __DIR__ . '/data/scheduled_posts.json'; + $postId = $_POST['id'] ?? ''; + $resultsJson = $_POST['results'] ?? '{}'; + $results = json_decode($resultsJson, true) ?: []; + + if (!$postId) { + echo json_encode(['error' => 'ID поста не указан']); + exit; + } + + $posts = file_exists($scheduledFile) ? json_decode(file_get_contents($scheduledFile), true) ?: [] : []; + $found = false; + + foreach ($posts as &$post) { + if (($post['id'] ?? null) === $postId && ($post['status'] ?? '') === 'pending') { + $post['status'] = 'published'; + $post['published_at'] = date('Y-m-d H:i:s'); + $post['results'] = $results; + $found = true; + break; + } + } + unset($post); + + if (!$found) { + echo json_encode(['error' => 'Пост не найден или уже опубликован']); + exit; + } + + if (file_put_contents($scheduledFile, json_encode($posts, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE))) { + echo json_encode(['success' => true]); + } else { + echo json_encode(['error' => 'Не удалось сохранить']); + } + break; + case 'get_published_posts': $scheduledFile = __DIR__ . '/data/scheduled_posts.json'; if (file_exists($scheduledFile)) { diff --git a/index.php b/index.php index d4ca10f..f1b8803 100644 --- a/index.php +++ b/index.php @@ -625,17 +625,18 @@ foreach ($channels as $ch) {
access_token из адресной строки браузера- Важно: Пользовательский токен позволяет загружать фото напрямую в VK. - Community-токен (ключ сообщества) может только постить текст и ссылки. + Важно: ключ сообщества бессрочный и не блокируется VK. Он постит и грузит фото только в свою группу — для нескольких групп создайте отдельный ключ в каждой. +
+
+ Старый способ через vkhost.github.io / VK Admin сейчас не работает — VK заблокировал это приложение (ошибка [8] Application is blocked).
${escapeHtml(post.text.substring(0, 100))}${post.text.length > 100 ? '...' : ''}
` : ''} + ${warningText ? `⚠ ${escapeHtml(warningText)}
` : ''} `; }).join('');