mirror of
https://github.com/twisterarmy/cloud-server.git
synced 2025-03-13 05:51:46 +00:00
init follow api
This commit is contained in:
parent
033a72052f
commit
f5f294bc90
0
src/application/controller/api/follow/add.php
Normal file
0
src/application/controller/api/follow/add.php
Normal file
0
src/application/controller/api/follow/delete.php
Normal file
0
src/application/controller/api/follow/delete.php
Normal file
0
src/application/controller/api/follow/get.php
Normal file
0
src/application/controller/api/follow/get.php
Normal file
36
src/application/controller/api/follow/total.php
Normal file
36
src/application/controller/api/follow/total.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
'success' => false,
|
||||||
|
'message' => _('Internal server error'),
|
||||||
|
'total' => 0
|
||||||
|
];
|
||||||
|
|
||||||
|
if (isset($_SESSION['userName'])) {
|
||||||
|
|
||||||
|
$userName = isset($_POST['userName']) ? $_POST['userName'] : $_SESSION['userName'];
|
||||||
|
|
||||||
|
$followingUsersTotal = 0;
|
||||||
|
|
||||||
|
foreach ((array) $_twister->getFollowing($_SESSION['userName']) as $followingUserName) {
|
||||||
|
$followingUsersTotal++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
'success' => true,
|
||||||
|
'message' => _('Follow totals received'),
|
||||||
|
'total' => $followingUsersTotal
|
||||||
|
];
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$response = [
|
||||||
|
'success' => false,
|
||||||
|
'message' => _('Session expired. Please, reload the page.'),
|
||||||
|
'total' => 0
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
|
echo json_encode($response);
|
Loading…
x
Reference in New Issue
Block a user