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:----JljVRlq2eAx016vH5SGWXWWdcJ3mVTntDnlZeXnl1zmvYOZkjg0tjZZKsOydc+wVZsjvuZYZ6QEnO/wQvXYQpF7YmiwViWCmpncElEDpvuOxAHiBZsXhJBjUPy3uQ1LnINDb3j0qt0JulxL11WCv/MqyT+G6OGx3mchKnlXMVZWwAejKY8Z0cvxjXsqopxVmORsdnYuBCmxbPKAvX+l/iwpvVPk2Mm2XNY0Apgi54ORZZdFyP2yb32b7M9hXu34J3BnH7ylE8hcVi1Jpv+jDfY4ujSXBR9Y+JFbLGxhp3vVck3IVtozz79WdkRMKfutduZwhccNV+UezCwWZWl5uaNei0uV4fsKWy0OsXnksB2HQ3d/sJTVYvYGig+GXsop6RZrfgG2CJ1dZzadQ0DqcbvwVAxueho5fEOcZr+HllvNs/lqvxS6IHQXw9FK1lxxmQCDJB7hV5HgzBsu2auHnEEUkrp5SLbeFi1/lbwMoVscVKSbA2eTEgRwK1CliI/+5Euw1cyyTlLh0YBb2oMM8ATeaenYtK+BzqX6rWuZb+bztBQbRzUW8RuZoNJ+9IiiTlVl2EoN7b+Un+hNO91KsUCA8aMKm33Y1/J745C7c11rLeA9BTTun8ue3HsuC00/sH5hAu1feymXMA0LRyLNWOTC8BR1ChDenicj2HChxA3s=----ATTACHMENT:----MzAzOTE2OTYwODczNzg3OCA0MjM5MTExNTE2MTQ0MDExIDM3NTQ1MTE5OTMwMTQ3ODQ=