2022-12-08 15:41:08 +00:00
|
|
|
<?php
|
|
|
|
|
2022-12-08 17:10:18 +00:00
|
|
|
$_ = function() {
|
2022-12-08 15:41:08 +00:00
|
|
|
$hostname = trim($_GET['hostname']);
|
|
|
|
|
|
|
|
$ch = curl_init();
|
|
|
|
curl_setopt($ch, CURLOPT_URL, "https://$hostname/.well-known/host-meta");
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
|
|
|
$output = curl_exec($ch);
|
|
|
|
curl_close($ch);
|
|
|
|
|
|
|
|
preg_match('/(?<=")[^"]+\/.well-known\/webfinger/', $output, $m);
|
|
|
|
if (count($m) === 0) {
|
|
|
|
return apiresult([
|
|
|
|
'error' => 'Could not find /.well-known/webfinger URL in instance given XML'
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
return apiresult([
|
|
|
|
'instance' => 'https://'.parse_url($m[0], PHP_URL_HOST),
|
|
|
|
]);
|
2022-12-08 17:10:18 +00:00
|
|
|
};
|
|
|
|
$_();
|