diff --git a/app/Services/WebfingerService.php b/app/Services/WebfingerService.php new file mode 100644 index 00000000..49628a5f --- /dev/null +++ b/app/Services/WebfingerService.php @@ -0,0 +1,40 @@ +run($query); + } + + protected function run($query) + { + $url = WebfingerUrl::generateWebfingerUrl($query); + if(!Helpers::validateUrl($url)) { + return []; + } + $res = Zttp::get($url); + $webfinger = $res->json(); + if(!isset($webfinger['links'])) { + return []; + } + $profile = Helpers::profileFetch($webfinger['links'][0]['href']); + $fractal = new Fractal\Manager(); + $fractal->setSerializer(new ArraySerializer()); + $resource = new Fractal\Resource\Item($profile, new AccountTransformer()); + $res = $fractal->createData($resource)->toArray(); + return $res; + } +} \ No newline at end of file