47 $engine->setService(static::getInstance());
48 $response = $engine->getSites();
50 if (!$response->isSuccess())
52 return [
'error' => $response->getErrors()];
56 $sites = $response->getData();
58 $sites = $sites[
'siteEntry'] ?? [];
59 foreach ($sites as $siteInfo)
61 $siteUrlInfo = parse_url($siteInfo[
'siteUrl']);
65 $hostKey = \CBXPunycode::toASCII($siteUrlInfo[
"host"], $errors);
66 if (count($errors) > 0)
68 $hostKey = $siteUrlInfo[
"host"];
72 'binded' => $siteInfo[
"permissionLevel"] !==
"siteRestrictedUser",
74 $siteInfo[
"permissionLevel"] !==
"siteRestrictedUser"
75 && $siteInfo[
"permissionLevel"] !==
"siteUnverifiedUser"
91 public static function addSite(
string $domain,
string $dir =
'/'): array
94 $protocol = $request->isHttps() ?
"https://" :
"http://";
97 $engine->setService(static::getInstance());
98 $response = $engine->addSite($protocol . $domain . $dir);
100 if (!$response->isSuccess())
102 return [
'error' => implode(
',', $response->getErrorMessages())];
105 $result = $response->getData();
106 if ($result[
'errors'])
108 return [
'error' => $result[
'errors'][
'message']];
111 return [
'result' =>
true];
125 $protocol = $request->isHttps() ?
"https://" :
"http://";
128 "identifier" => $protocol . $domain . $dir,
131 "verificationMethod" =>
"FILE",
135 $engine->setService(static::getInstance());
136 $response = $engine->getVerifyToken($data);
138 if (!$response->isSuccess())
140 return [
'error' => implode(
',', $response->getErrorMessages())];
143 $result = $response->getData();
144 if (!$result || !$result[
"token"])
146 return [
'error' =>
'empty response'];
148 if ($result[
'errors'])
150 return [
'error' => $result[
'errors'][
'message']];
153 return [
'token' => $result[
"token"]];
164 public static function verifySite(
string $domain,
string $dir =
'/'): array
167 $protocol = $request->isHttps() ?
"https://" :
"http://";
170 "identifier" => $protocol . $domain . $dir,
176 $engine->setService(static::getInstance());
177 $response = $engine->verifySite($data);
179 if (!$response->isSuccess())
181 return [
'error' => implode(
',', $response->getErrorMessages())];
184 $result = $response->getData();
185 if (!$result || !$result[
"token"])
187 return [
'error' =>
'empty response'];
189 if ($result[
'errors'])
191 return [
'error' => $result[
'errors'][
'message']];
194 return [
'result' =>
true];