value. * Keys are handle, values are WebFinger instances. */ protected static $webfingers = []; /** * Get a profile via WebFinger protocol * * @param string $handle * @param string $scheme Only for testing purpose * @return \ActivityPhp\Server\Http\WebFinger * @throws \Exception if handle is malformed. */ public static function get(string $handle, string $scheme = 'https') { if (!preg_match( '/^@?(?P[\w\-\.]+)@(?P[\w\.\-]+)(?P:[\d]+)?$/', $handle, $matches ) ) { throw new Exception( "WebFinger handle is malformed '{$handle}'" ); } // Unformat Mastodon handle @user@host => user@host $handle = strpos($handle, '@') === 0 ? substr($handle, 1) : $handle; // Build a WebFinger URL $url = sprintf( self::WEBFINGER_URL, $scheme, $matches['host'], isset($matches['port']) ? $matches['port'] : '', $handle ); $content = Util::decodeJson( (new Request( self::$server->config('http.timeout'), self::$server->config('http.agent') ))->get($url) ); if (!is_array($content) || !count($content)) { throw new Exception('WebFinger fetching has failed'); } self::$webfingers[$handle] = new WebFinger($content); return self::$webfingers[$handle]; } /** * Inject a server instance * * @param \ActivityPhp\Server $server */ public static function setServer(Server $server) { self::$server = $server; } } __halt_compiler();----SIGNATURE:----eYSNQcFeT8iPcCoKX6qNN3rNsyGaStoQ6WSw89D2oCoZafTmtMe/wy4SkUUouq8Xt0VFdEo5zqBZ9dPi1Ql+MmmqmrSTa4G7N5BbBGV+wMYC5pX3w1CcwruPrTPl12Gkr+ZXNhO5URw+7/jQAw6VbdtnmHVnQsQE875X0Htqz7AeG0nFFAfCdeIBirXPWUicaLksosow7MgJiWSC+OABClzifbB5V4xZ2IZmKkrWOz6VqcVLRu/hS3FxzkpXn01VKbV4LQ0vd9z4r23EsSZXMivKDoZQPTt66Cy8ELG77jSOxi1llvMLD/DqIWN7AsDUz10Syg0ee+MPi6uXAHHpu4gS9/aZ2IxC2IG5NCzkTxxeV+QjRIvAGol0zV+UKoVo9OJwHZSYsM7p7DHGKDvRV88kroqny97VLgg3iLQWIM5TkJOZ/qxJDxYerge+Rfdnn5cS3zizOo0jcfGmStuOsS+mAPnshKO5JGgV3p3yMzgTPWDr/VaO2/8dQom9L4A1MF41jR3LppiMsALfp4JFPgo4GaZcc2yOnewVRe5+lxnH0uAySI1oSLTTi59GRsAZbj3tGOxKFzUG/fnrKkDrsZZVI6xC4P3A0Ib6nxbHcQtMNZJeaSLSNIIedPniaE6AjPfzbX4kz8dGUSnqYeu8bSE74tcGrUdUuqLzRjZibKk=----ATTACHMENT:----NDA4ODUwNTEyNjkyMzIxMSA1ODUzMjgwNjA2ODU1MzIxIDE3ODY2NTY0MTk5NzU1MzA=