<?php
// Test UDN publishing directly
require_once 'src/config/config.php';

$publisher = new Publisher();
$article = new Article();

// Get an external article
$testArticle = $article->getById(3);
if ($testArticle && $testArticle['type'] === 'external') {
    echo "Testing UDN Blog publishing with article: " . $testArticle['title'] . "\n";

    // Get UDN platform info
    $database = new Database();
    $db = $database->getConnection();
    $stmt = $db->prepare("SELECT * FROM external_platforms WHERE name LIKE '%UDN%'");
    $stmt->execute();
    $udnPlatform = $stmt->fetch();

    if ($udnPlatform) {
        echo "Found UDN platform: " . $udnPlatform['name'] . "\n";

        // Test publishing
        $result = $publisher->publishToSelectedPlatforms(3, [$udnPlatform['id']]);

        echo "Publishing result:\n";
        print_r($result);
    } else {
        echo "UDN platform not found\n";
    }
} else {
    echo "Test article not found or not external\n";
}
?>