$user
));
- // Selecting the id by priority, friendica first
- if (is_array($uinfo)) {
+ if (DBA::isResult($uinfo)) {
+ // Selecting the id by priority, friendica first
api_best_nickname($uinfo);
+ return DI::twitterUser()->createFromContactId($uinfo[0]['cid'], $uinfo[0]['uid'])->toArray();
}
- // if the contact wasn't found, fetch it from the contacts with uid = 0
- if (!DBA::isResult($uinfo)) {
- if ($url == "") {
- throw new BadRequestException("User not found.");
- }
-
- $contact = DBA::selectFirst('contact', [], ['uid' => 0, 'nurl' => Strings::normaliseLink($url)]);
-
- if (DBA::isResult($contact)) {
- $ret = [
- 'id' => $contact["id"],
- 'id_str' => (string) $contact["id"],
- 'name' => $contact["name"],
- 'screen_name' => (($contact['nick']) ? $contact['nick'] : $contact['name']),
- 'location' => ($contact["location"] != "") ? $contact["location"] : ContactSelector::networkToName($contact['network'], $contact['url'], $contact['protocol']),
- 'description' => BBCode::toPlaintext($contact["about"] ?? ''),
- 'profile_image_url' => Contact::getAvatarUrlForUrl($contact['url'], api_user(), Proxy::SIZE_MICRO),
- 'profile_image_url_https' => Contact::getAvatarUrlForUrl($contact['url'], api_user(), Proxy::SIZE_MICRO),
- 'profile_image_url_profile_size' => Contact::getAvatarUrlForUrl($contact['url'], api_user(), Proxy::SIZE_THUMB),
- 'profile_image_url_large' => Contact::getAvatarUrlForUrl($contact['url'], api_user(), Proxy::SIZE_SMALL),
- 'url' => $contact["url"],
- 'protected' => false,
- 'followers_count' => 0,
- 'friends_count' => 0,
- 'listed_count' => 0,
- 'created_at' => api_date($contact["created"]),
- 'favourites_count' => 0,
- 'utc_offset' => 0,
- 'time_zone' => 'UTC',
- 'geo_enabled' => false,
- 'verified' => false,
- 'statuses_count' => 0,
- 'lang' => '',
- 'contributors_enabled' => false,
- 'is_translator' => false,
- 'is_translation_enabled' => false,
- 'following' => false,
- 'follow_request_sent' => false,
- 'statusnet_blocking' => false,
- 'notifications' => false,
- 'statusnet_profile_url' => $contact["url"],
- 'uid' => 0,
- 'cid' => Contact::getIdForURL($contact["url"], api_user(), false),
- 'pid' => Contact::getIdForURL($contact["url"], 0, false),
- 'self' => 0,
- 'network' => $contact["network"],
- ];
-
- return $ret;
- } else {
- throw new BadRequestException("User ".$url." not found.");
- }
+ if ($url == "") {
+ throw new BadRequestException("User not found.");
}
- if ($uinfo[0]['self']) {
- if ($uinfo[0]['network'] == "") {
- $uinfo[0]['network'] = Protocol::DFRN;
- }
+ $cid = Contact::getIdForURL($url, 0, false);
- $usr = DBA::selectFirst('user', ['default-location'], ['uid' => api_user()]);
- $profile = DBA::selectFirst('profile', ['about'], ['uid' => api_user(), 'is-default' => true]);
- }
- $countitems = 0;
- $countfriends = 0;
- $countfollowers = 0;
- $starred = 0;
-
- $pcontact_id = Contact::getIdForURL($uinfo[0]['url'], 0, false);
-
- if (!empty($profile['about'])) {
- $description = $profile['about'];
+ if (!empty($cid)) {
+ return DI::twitterUser()->createFromContactId($cid, 0)->toArray();
} else {
- $description = $uinfo[0]["about"];
+ throw new BadRequestException("User ".$url." not found.");
}
-
- if (!empty($usr['default-location'])) {
- $location = $usr['default-location'];
- } elseif (!empty($uinfo[0]["location"])) {
- $location = $uinfo[0]["location"];
- } else {
- $location = ContactSelector::networkToName($uinfo[0]['network'], $uinfo[0]['url'], $uinfo[0]['protocol']);
- }
-
- $ret = [
- 'id' => intval($pcontact_id),
- 'id_str' => (string) intval($pcontact_id),
- 'name' => (($uinfo[0]['name']) ? $uinfo[0]['name'] : $uinfo[0]['nick']),
- 'screen_name' => (($uinfo[0]['nick']) ? $uinfo[0]['nick'] : $uinfo[0]['name']),
- 'location' => $location,
- 'description' => BBCode::toPlaintext($description ?? ''),
- 'profile_image_url' => Contact::getAvatarUrlForUrl($uinfo[0]['url'], api_user(), Proxy::SIZE_MICRO),
- 'profile_image_url_https' => Contact::getAvatarUrlForUrl($uinfo[0]['url'], api_user(), Proxy::SIZE_MICRO),
- 'profile_image_url_profile_size' => Contact::getAvatarUrlForUrl($uinfo[0]['url'], api_user(), Proxy::SIZE_THUMB),
- 'profile_image_url_large' => Contact::getAvatarUrlForUrl($uinfo[0]['url'], api_user(), Proxy::SIZE_SMALL),
- 'url' => $uinfo[0]['url'],
- 'protected' => false,
- 'followers_count' => intval($countfollowers),
- 'friends_count' => intval($countfriends),
- 'listed_count' => 0,
- 'created_at' => api_date($uinfo[0]['created']),
- 'favourites_count' => intval($starred),
- 'utc_offset' => "0",
- 'time_zone' => 'UTC',
- 'geo_enabled' => false,
- 'verified' => true,
- 'statuses_count' => intval($countitems),
- 'lang' => '',
- 'contributors_enabled' => false,
- 'is_translator' => false,
- 'is_translation_enabled' => false,
- 'following' => (($uinfo[0]['rel'] == Contact::FOLLOWER) || ($uinfo[0]['rel'] == Contact::FRIEND)),
- 'follow_request_sent' => false,
- 'statusnet_blocking' => false,
- 'notifications' => false,
- /// @TODO old way?
- //'statusnet_profile_url' => DI::baseUrl()."/contact/".$uinfo[0]['cid'],
- 'statusnet_profile_url' => $uinfo[0]['url'],
- 'uid' => intval($uinfo[0]['uid']),
- 'cid' => intval($uinfo[0]['cid']),
- 'pid' => Contact::getIdForURL($uinfo[0]["url"], 0, false),
- 'self' => $uinfo[0]['self'],
- 'network' => $uinfo[0]['network'],
- ];
-
- // If this is a local user and it uses Frio, we can get its color preferences.
- if ($ret['self']) {
- $theme_info = DBA::selectFirst('user', ['theme'], ['uid' => $ret['uid']]);
- if ($theme_info['theme'] === 'frio') {
- $schema = DI::pConfig()->get($ret['uid'], 'frio', 'schema');
-
- if ($schema && ($schema != '---')) {
- if (file_exists('view/theme/frio/schema/'.$schema.'.php')) {
- $schemefile = 'view/theme/frio/schema/'.$schema.'.php';
- require_once $schemefile;
- }
- } else {
- $nav_bg = DI::pConfig()->get($ret['uid'], 'frio', 'nav_bg');
- $link_color = DI::pConfig()->get($ret['uid'], 'frio', 'link_color');
- $bgcolor = DI::pConfig()->get($ret['uid'], 'frio', 'background_color');
- }
- if (empty($nav_bg)) {
- $nav_bg = "#708fa0";
- }
- if (empty($link_color)) {
- $link_color = "#6fdbe8";
- }
- if (empty($bgcolor)) {
- $bgcolor = "#ededed";
- }
-
- $ret['profile_sidebar_fill_color'] = str_replace('#', '', $nav_bg);
- $ret['profile_link_color'] = str_replace('#', '', $link_color);
- $ret['profile_background_color'] = str_replace('#', '', $bgcolor);
- }
- }
-
- return $ret;
}
/**
--- /dev/null
+<?php
+/**
+ * @copyright Copyright (C) 2010-2021, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Friendica\Module\Api\Twitter\Followers;
+
+use Friendica\Core\System;
+use Friendica\Model\Contact;
+use Friendica\Module\Api\Twitter\ContactEndpoint;
+
+/**
+ * @see https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-followers-ids
+ */
+class FollowersIds extends ContactEndpoint
+{
+ public static function rawContent(array $parameters = [])
+ {
+ // Expected value for user_id parameter: public/user contact id
+ $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);
+ $stringify_ids = filter_input(INPUT_GET, 'stringify_ids', FILTER_VALIDATE_BOOLEAN);
+ $count = filter_input(INPUT_GET, 'count' , FILTER_VALIDATE_INT, ['options' => [
+ 'default' => self::DEFAULT_COUNT,
+ 'min_range' => 1,
+ 'max_range' => self::MAX_COUNT,
+ ]]);
+ // 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::ids(
+ [Contact::FOLLOWER, Contact::FRIEND],
+ self::getUid($contact_id, $screen_name),
+ $cursor ?? $since_id ?? - $max_id,
+ $count,
+ $stringify_ids
+ ));
+ }
+}
--- /dev/null
+<?php
+/**
+ * @copyright Copyright (C) 2010-2021, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Friendica\Module\Api\Twitter\Followers;
+
+use Friendica\Core\System;
+use Friendica\Model\Contact;
+use Friendica\Module\Api\Twitter\ContactEndpoint;
+
+/**
+ * @see https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-followers-list
+ */
+class FollowersList extends ContactEndpoint
+{
+ public static function rawContent(array $parameters = [])
+ {
+ // Expected value for user_id parameter: public/user contact id
+ $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 ?? $since_id ?? - $max_id,
+ $count,
+ $skip_status,
+ $include_user_entities
+ ));
+ }
+}
+++ /dev/null
-<?php
-/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- */
-
-namespace Friendica\Module\Api\Twitter;
-
-use Friendica\Core\System;
-use Friendica\Model\Contact;
-
-/**
- * @see https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-followers-ids
- */
-class FollowersIds extends ContactEndpoint
-{
- public static function rawContent(array $parameters = [])
- {
- // Expected value for user_id parameter: public/user contact id
- $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);
- $stringify_ids = filter_input(INPUT_GET, 'stringify_ids', FILTER_VALIDATE_BOOLEAN);
- $count = filter_input(INPUT_GET, 'count' , FILTER_VALIDATE_INT, ['options' => [
- 'default' => self::DEFAULT_COUNT,
- 'min_range' => 1,
- 'max_range' => self::MAX_COUNT,
- ]]);
- // 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::ids(
- [Contact::FOLLOWER, Contact::FRIEND],
- self::getUid($contact_id, $screen_name),
- $cursor ?? $since_id ?? - $max_id,
- $count,
- $stringify_ids
- ));
- }
-}
+++ /dev/null
-<?php
-/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- */
-
-namespace Friendica\Module\Api\Twitter;
-
-use Friendica\Core\System;
-use Friendica\Model\Contact;
-
-/**
- * @see https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-followers-list
- */
-class FollowersList extends ContactEndpoint
-{
- public static function rawContent(array $parameters = [])
- {
- // Expected value for user_id parameter: public/user contact id
- $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 ?? $since_id ?? - $max_id,
- $count,
- $skip_status,
- $include_user_entities
- ));
- }
-}
--- /dev/null
+<?php
+/**
+ * @copyright Copyright (C) 2010-2021, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Friendica\Module\Api\Twitter\Friends;
+
+use Friendica\Core\System;
+use Friendica\Model\Contact;
+use Friendica\Module\Api\Twitter\ContactEndpoint;
+
+/**
+ * @see https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friends-ids
+ */
+class Ids extends ContactEndpoint
+{
+ public static function rawContent(array $parameters = [])
+ {
+ // Expected value for user_id parameter: public/user contact id
+ $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);
+ $stringify_ids = filter_input(INPUT_GET, 'stringify_ids', FILTER_VALIDATE_BOOLEAN);
+ $count = filter_input(INPUT_GET, 'count' , FILTER_VALIDATE_INT, ['options' => [
+ 'default' => self::DEFAULT_COUNT,
+ 'min_range' => 1,
+ 'max_range' => self::MAX_COUNT,
+ ]]);
+ // 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::ids(
+ [Contact::SHARING, Contact::FRIEND],
+ self::getUid($contact_id, $screen_name),
+ $cursor ?? $since_id ?? - $max_id,
+ $count,
+ $stringify_ids
+ ));
+ }
+}
--- /dev/null
+<?php
+/**
+ * @copyright Copyright (C) 2010-2021, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Friendica\Module\Api\Twitter\Friends;
+
+use Friendica\Core\System;
+use Friendica\Model\Contact;
+use Friendica\Module\Api\Twitter\ContactEndpoint;
+
+/**
+ * @see https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friends-list
+ */
+class Lists extends ContactEndpoint
+{
+ public static function rawContent(array $parameters = [])
+ {
+ // Expected value for user_id parameter: public/user contact id
+ $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 ?? $since_id ?? - $max_id,
+ $count,
+ $skip_status,
+ $include_user_entities
+ ));
+ }
+}
+++ /dev/null
-<?php
-/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- */
-
-namespace Friendica\Module\Api\Twitter;
-
-use Friendica\Core\System;
-use Friendica\Model\Contact;
-
-/**
- * @see https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friends-ids
- */
-class FriendsIds extends ContactEndpoint
-{
- public static function rawContent(array $parameters = [])
- {
- // Expected value for user_id parameter: public/user contact id
- $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);
- $stringify_ids = filter_input(INPUT_GET, 'stringify_ids', FILTER_VALIDATE_BOOLEAN);
- $count = filter_input(INPUT_GET, 'count' , FILTER_VALIDATE_INT, ['options' => [
- 'default' => self::DEFAULT_COUNT,
- 'min_range' => 1,
- 'max_range' => self::MAX_COUNT,
- ]]);
- // 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::ids(
- [Contact::SHARING, Contact::FRIEND],
- self::getUid($contact_id, $screen_name),
- $cursor ?? $since_id ?? - $max_id,
- $count,
- $stringify_ids
- ));
- }
-}
+++ /dev/null
-<?php
-/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- */
-
-namespace Friendica\Module\Api\Twitter;
-
-use Friendica\Core\System;
-use Friendica\Model\Contact;
-
-/**
- * @see https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friends-list
- */
-class FriendsList extends ContactEndpoint
-{
- public static function rawContent(array $parameters = [])
- {
- // Expected value for user_id parameter: public/user contact id
- $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 ?? $since_id ?? - $max_id,
- $count,
- $skip_status,
- $include_user_entities
- ));
- }
-}
use Friendica\BaseDataTransferObject;
use Friendica\Content\ContactSelector;
use Friendica\Content\Text\BBCode;
+use Friendica\Core\Protocol;
+use Friendica\Model\Contact;
+use Friendica\Util\Proxy;
/**
* @see https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/user-object
/** @var string */
protected $withheld_scope;
+ /**
+ * Missing fields:
+ *
+ * - profile_sidebar_fill_color
+ * - profile_link_color
+ * - profile_background_color
+ */
+
/**
* @param array $publicContact Full contact table record with uid = 0
* @param array $apcontact Optional full apcontact table record
*/
public function __construct(array $publicContact, array $apcontact = [], array $userContact = [], $skip_status = false, $include_user_entities = true)
{
+ $uid = $userContact['uid'] ?? 0;
+
$this->id = (int)$publicContact['id'];
$this->id_str = (string) $publicContact['id'];
- $this->name = $publicContact['name'];
+ $this->name = $publicContact['name'] ?: $publicContact['nick'];
$this->screen_name = $publicContact['nick'] ?: $publicContact['name'];
$this->location = $publicContact['location'] ?:
ContactSelector::networkToName($publicContact['network'], $publicContact['url'], $publicContact['protocol']);
unset($this->entities);
}
$this->description = BBCode::toPlaintext($publicContact['about']);
- $this->profile_image_url_https = $userContact['avatar'] ?? $publicContact['avatar'];
+ $this->profile_image_url_https = Contact::getAvatarUrlForUrl($publicContact['url'], $uid, Proxy::SIZE_MICRO);
$this->protected = false;
$this->followers_count = $apcontact['followers_count'] ?? 0;
$this->friends_count = $apcontact['following_count'] ?? 0;
$this->listed_count = 0;
$this->created_at = api_date($publicContact['created']);
$this->favourites_count = 0;
- $this->verified = false;
+ $this->verified = $uid != 0;
$this->statuses_count = $apcontact['statuses_count'] ?? 0;
$this->profile_banner_url = '';
$this->default_profile = false;
unset($this->withheld_scope);
// Deprecated
- $this->profile_image_url = $userContact['avatar'] ?? $publicContact['avatar'];
- $this->profile_image_url_profile_size = $publicContact['thumb'];
- $this->profile_image_url_large = $publicContact['photo'];
+ $this->profile_image_url = Contact::getAvatarUrlForUrl($publicContact['url'], $uid, Proxy::SIZE_MICRO);
+ $this->profile_image_url_profile_size = Contact::getAvatarUrlForUrl($publicContact['url'], $uid, Proxy::SIZE_THUMB);
+ $this->profile_image_url_large = Contact::getAvatarUrlForUrl($publicContact['url'], $uid, Proxy::SIZE_LARGE);
$this->utc_offset = 0;
$this->time_zone = 'UTC';
$this->geo_enabled = false;
$this->contributors_enabled = false;
$this->is_translator = false;
$this->is_translation_enabled = false;
- $this->following = false;
+ $this->following = in_array($userContact['rel'] ?? Contact::NOTHING, [Contact::FOLLOWER, Contact::FRIEND]);
$this->follow_request_sent = false;
$this->statusnet_blocking = false;
$this->notifications = false;
// Friendica-specific
- $this->uid = (int)$userContact['uid'] ?? 0;
- $this->cid = (int)$userContact['id'] ?? 0;
+ $this->uid = (int)$uid;
+ $this->cid = (int)($userContact['id'] ?? 0);
$this->pid = (int)$publicContact['id'];
- $this->self = (boolean)$userContact['self'] ?? false;
- $this->network = $publicContact['network'];
+ $this->self = (boolean)($userContact['self'] ?? false);
+ $this->network = $publicContact['network'] ?: Protocol::DFRN;
$this->statusnet_profile_url = $publicContact['url'];
}
}
'/update_profile_image[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [ R::POST]],
],
- '/blocks/list[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [R::GET ]],
- '/conversation/show[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [R::GET ]],
+ '/blocks/list[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [R::GET ]],
+ '/conversation/show[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [R::GET ]],
'/direct_messages' => [
- '/all[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [R::GET ]],
- '/conversation[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [R::GET ]],
- '/destroy[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [R::DELETE, R::POST]],
- '/new[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [ R::POST]],
- '/sent[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [R::GET ]],
+ '/all[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [R::GET ]],
+ '/conversation[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [R::GET ]],
+ '/destroy[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [R::DELETE, R::POST]],
+ '/new[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [ R::POST]],
+ '/sent[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [R::GET ]],
],
- '/direct_messages[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [R::GET, R::POST]],
-
- '/externalprofile/show[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [R::GET ]],
- '/favorites/create[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [ R::POST]],
- '/favorites/destroy[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [R::DELETE, R::POST]],
- '/favorites[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [R::GET ]],
- '/followers/ids[.{extension:json|xml|rss|atom}]' => [Module\Api\Twitter\FollowersIds::class, [R::GET ]],
- '/followers/list[.{extension:json|xml|rss|atom}]' => [Module\Api\Twitter\FollowersList::class, [R::GET ]],
- '/friends/ids[.{extension:json|xml|rss|atom}]' => [Module\Api\Twitter\FriendsIds::class, [R::GET ]],
- '/friends/list[.{extension:json|xml|rss|atom}]' => [Module\Api\Twitter\FriendsList::class, [R::GET ]],
- '/friendships/destroy[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [ R::POST]],
- '/friendships/incoming[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [R::GET ]],
+ '/direct_messages[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [R::GET, R::POST]],
+
+ '/externalprofile/show[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [R::GET ]],
+ '/favorites/create[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [ R::POST]],
+ '/favorites/destroy[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [R::DELETE, R::POST]],
+ '/favorites[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [R::GET ]],
+ '/followers/ids[.{extension:json|xml|rss|atom}]' => [Module\Api\Twitter\Followers\Ids::class, [R::GET ]],
+ '/followers/list[.{extension:json|xml|rss|atom}]' => [Module\Api\Twitter\Followers\Lists::class, [R::GET ]],
+ '/friends/ids[.{extension:json|xml|rss|atom}]' => [Module\Api\Twitter\Friends\Ids::class, [R::GET ]],
+ '/friends/list[.{extension:json|xml|rss|atom}]' => [Module\Api\Twitter\Friends\Lists::class, [R::GET ]],
+ '/friendships/destroy[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [ R::POST]],
+ '/friendships/incoming[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Index::class, [R::GET ]],
'/friendica' => [
'/activity/{verb:attendmaybe|attendno|attendyes|dislike|like|unattendmaybe|unattendno|unattendyes|undislike|unlike}[.{extension:json|xml|rss|atom}]'