egytalk-sveltekit/www/public/api/getposts.php

22 lines
519 B
PHP

<?php
session_start();
$result= [];
$statusCode = 401;
if (isset($_SESSION['uid'])){
include('../../model/DbEgyTalk.php');
$db = new DbEgyTalk();
$uid = $_SESSION['uid'];
if(isset($_GET['uid']) && !empty($db->getUserFromUid($_GET['uid']))){
$uid = $_GET['uid'];
$result = $db->getPosts($uid);
$statusCode = 200;
}else{
$statusCode = 400;
}
}
http_response_code($statusCode);
header('Content-Type: application/json');
echo json_encode($result, JSON_UNESCAPED_UNICODE);