]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Api/Twitter/FollowersList.php
Merge pull request #10986 from annando/issue-10983
[friendica.git] / src / Module / Api / Twitter / FollowersList.php
index 867272bfba84f73643185bb5385ea3f66517c5a0..8e39f220199bbb2f6ce551c9126bd6088af040a4 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -32,17 +32,28 @@ class FollowersList extends ContactEndpoint
        public static function rawContent(array $parameters = [])
        {
                // Expected value for user_id parameter: public/user contact id
-               $contact_id  = $_GET['user_id'] ?? null;
-               $screen_name = $_GET['screen_name'] ?? null;
-               $cursor      = $_GET['cursor'] ?? $_GET['since_id'] ?? -1;
-               $count       = min((int) ($_GET['count'] ?? self::DEFAULT_COUNT), self::MAX_COUNT);
-               $skip_status = in_array(($_GET['skip_status'] ?? false), [true, 'true', 't', 1, '1']);
-               $include_user_entities = ($_GET['include_user_entities'] ?? 'true') != 'false';
+               $contact_id    = filter_input(INPUT_GET, 'user_id'      , FILTER_VALIDATE_INT);
+               $screen_name   = filter_input(INPUT_GET, 'screen_name');
+               $cursor        = filter_input(INPUT_GET, 'cursor'       , FILTER_VALIDATE_INT);
+               $count         = filter_input(INPUT_GET, 'count'        , FILTER_VALIDATE_INT, ['options' => [
+                       'default' => self::DEFAULT_COUNT,
+                       'min_range' => 1,
+                       'max_range' => self::MAX_COUNT,
+               ]]);
+               $skip_status           = filter_input(INPUT_GET, 'skip_status'          , FILTER_VALIDATE_BOOLEAN);
+               $include_user_entities = filter_input(INPUT_GET, 'include_user_entities', FILTER_VALIDATE_BOOLEAN);
+
+               // Friendica-specific
+               $since_id      = filter_input(INPUT_GET, 'since_id'     , FILTER_VALIDATE_INT);
+               $max_id        = filter_input(INPUT_GET, 'max_id'       , FILTER_VALIDATE_INT, ['options' => [
+                       'default' => 1,
+               ]]);
+
 
                System::jsonExit(self::list(
                        [Contact::FOLLOWER, Contact::FRIEND],
                        self::getUid($contact_id, $screen_name),
-                       $cursor,
+                       $cursor ?? $since_id ?? - $max_id,
                        $count,
                        $skip_status,
                        $include_user_entities