. * */ namespace Friendica\Module\Api\Mastodon; use Friendica\Core\System; use Friendica\DI; use Friendica\Model\Tag; use Friendica\Module\BaseApi; /** * @see https://docs.joinmastodon.org/methods/instance/trends/ */ class Trends extends BaseApi { /** * @param array $parameters * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ public static function rawContent(array $parameters = []) { // Maximum number of results to return. Defaults to 10. $limit = (int)!isset($_REQUEST['limit']) ? 10 : $_REQUEST['limit']; $trending = []; $tags = Tag::getGlobalTrendingHashtags(24, 20); foreach ($tags as $tag) { $tag['name'] = $tag['term']; $hashtag = new \Friendica\Object\Api\Mastodon\Tag(DI::baseUrl(), $tag); $trending[] = $hashtag->toArray(); } System::jsonExit(array_slice($trending, 0, $limit)); } }