Browse Source

implement follow feature

main
ghost 3 years ago
parent
commit
5b3323185f
  1. 27
      src/application/controller/api/follow/add.php
  2. 4
      src/application/controller/api/follow/delete.php
  3. 3
      src/bootstrap.php

27
src/application/controller/api/follow/add.php

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
<?php
$response = [
'success' => false,
'message' => _('Internal server error'),
];
if (isset($_SESSION['userName']) && isset($_POST['userName'])) {
$result = $_twister->follow($_SESSION['userName'], [$_POST['userName']]);
$response = [
'success' => true,
'message' => _('Followed successfully'),
];
} else {
$response = [
'success' => false,
'message' => _('Session expired. Please, reload the page.'),
];
}
header('Content-Type: application/json; charset=utf-8');
echo json_encode($response);

4
src/application/controller/api/follow/delete.php

@ -5,9 +5,7 @@ $response = [ @@ -5,9 +5,7 @@ $response = [
'message' => _('Internal server error'),
];
if (isset($_SESSION['userName'])) {
$userName = isset($_POST['userName']) ? $_POST['userName'] : false;
if (isset($_SESSION['userName']) && isset($_POST['userName'])) {
$result = $_twister->unFollow($_SESSION['userName'], [$_POST['userName']]);

3
src/bootstrap.php

@ -79,6 +79,9 @@ if (isset($_GET['_route_'])) { @@ -79,6 +79,9 @@ if (isset($_GET['_route_'])) {
case 'api/follow/get':
require(PROJECT_DIR . '/application/controller/api/follow/get.php');
break;
case 'api/follow/add':
require(PROJECT_DIR . '/application/controller/api/follow/add.php');
break;
case 'api/follow/delete':
require(PROJECT_DIR . '/application/controller/api/follow/delete.php');
break;

Loading…
Cancel
Save