mirror of
https://github.com/friendica/friendica
synced 2025-04-28 11:44:23 +02:00
Add support for max_id parameter in new Twitter contact API endpoints
- Use filter_input instead of manual type casting
This commit is contained in:
parent
7a5afc10bb
commit
8111ede2e5
6 changed files with 112 additions and 50 deletions
|
@ -32,17 +32,27 @@ class FriendsList 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::SHARING, Contact::FRIEND],
|
||||
self::getUid($contact_id, $screen_name),
|
||||
$cursor,
|
||||
$cursor ?? $since_id ?? - $max_id,
|
||||
$count,
|
||||
$skip_status,
|
||||
$include_user_entities
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue