<?php
require_once __DIR__.'/../../_bootstrap.php';$u=apiUsuario($pdo);if($_SERVER['REQUEST_METHOD']!=='GET')jsonResponse(['ok'=>false,'erro'=>'Método não permitido.'],405);$uid=(int)$u['id'];$subjectId=(int)($_GET['subject_user_id']??$uid);
try{$data=afPrivacyBuildExport($pdo,$uid,$subjectId);$encoded=json_encode($data,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_INVALID_UTF8_SUBSTITUTE);$protocol=afLogPrivacyExport($pdo,$uid,$subjectId,$data,hash('sha256',(string)$encoded));jsonResponse(['ok'=>true,'protocol'=>$protocol,'export'=>$data]);}catch(Throwable $e){jsonResponse(['ok'=>false,'erro'=>$e->getMessage()],403);}
