<?php
// socialmediamanager/api/publish_now.php
require_once __DIR__ . "/../app/db.php";
require_once __DIR__ . "/../app/publisher.php";

try{
  $b=smm_read_json_body();
  $id=intval($b["article_id"]??0);
  if($id<=0) smm_json_response(["ok"=>false,"error"=>"article_id required"],400);
  $pdo=smm_db();
  $res = smm_publish_article($pdo, $id);
  smm_json_response($res);
} catch(Throwable $e){
  smm_log("publish_now error: ".$e->getMessage(),"ERROR");
  smm_json_response(["ok"=>false,"error"=>$e->getMessage()],500);
}
