public function getProxy() { return Service::getEngine(); }
require_once $_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/main/include/prolog_before.php"; if (CModule::IncludeModule("socialservices") && CSocServAuthManager::CheckUniqueKey()) { if (isset($_REQUEST["authresult"])) { $engine = $_REQUEST["engine"]; \Bitrix\Seo\Service::clearAuth($engine, true); ?> <script type="text/javascript"> opener.location.reload(); window.close(); </script> <?php } else { $result = array(); $state = $_REQUEST["state"]; if (isset($_REQUEST["code"]) && $_REQUEST["code"] != '') { $engine = \Bitrix\Seo\Service::getEngine(); $engine->getInterface()->setCode($_REQUEST["code"]); if ($engine->getInterface()->GetAccessToken() !== false) { $engine->setAuthSettings($engine->getInterface()->getResult()); $result["result"] = "ok"; } else { $result = $engine->getInterface()->getError(); } } else { $result["error"] = "Wrong request"; } Header("Content-Type: application/json"); echo \Bitrix\Main\Web\Json::encode($result); } } require_once $_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/main/include/epilog_after.php";
public function getCurrentUser() { if (Service::isAuthorized($this->getCode())) { $currentAuth = Service::getAuth($this->getCode()); return $currentAuth['user']; } else { return false; } }
case 'register': if (!Service::isRegistered()) { try { Service::register(); $res = array("result" => true); } catch (\Bitrix\Main\SystemException $e) { $res = array('error' => array('message' => $e->getMessage(), 'code' => $e->getCode())); } } break; case 'authorize': $authResult = Service::authorize(); $res = array("result" => true, "location" => $authResult["location"]); break; case 'nullify_auth': Service::clearAuth($engine->getCode()); $res = array("result" => true); break; case 'wordstat_report_clear': case 'wordstat_report': if ($_REQUEST['action'] == 'wordstat_report_clear') { $reportList = $engine->getWordstatReportList(); if (count($reportList) >= Engine\YandexDirect::MAX_WORDSTAT_REPORTS) { foreach ($reportList as $firstReport) { $engine->deleteWordstatReport($firstReport["ReportID"]); break; } } } $phraseList = $_REQUEST['phrase']; $geo = trim($_REQUEST['geo']);
} elseif (!Service::isAuthorized()) { $authAction = "authorizeClient();"; ?> <input type=button onclick="<?php echo $authAction; ?> " value="<?php echo Loc::getMessage('SEO_AUTH_YANDEX'); ?> " id="seo_authorize_btn" /> <?php } else { $authInfo = Service::getAuth($engine->getCode()); if (!$authInfo) { $authorizeUrl = Service::getAuthorizeLink($engine->getCode()); ?> <input type=button onclick="authorizeUser('<?php echo $authorizeUrl; ?> ')" value="<?php echo Loc::getMessage('SEO_AUTH_YANDEX'); ?> " id="seo_authorize_btn"/> <?php } else { $currentUser = $authInfo['user']; ?> <div id="auth_result" class="seo-auth-result"> <b><?php echo Loc::getMessage('SEO_AUTH_CURRENT');
public function call($methodName, $additionalParams = null) { global $APPLICATION; if (!$this->access_token) { $interface = Service::getEngine()->getInterface(); if (!$interface->checkAccessToken()) { if ($interface->getNewAccessToken()) { Service::getEngine()->setAuthSettings($interface->getResult()); } else { return $interface->getResult(); } } $this->access_token = $interface->getToken(); } if ($this->access_token) { if (!is_array($additionalParams)) { $additionalParams = array(); } else { $additionalParams = $APPLICATION->ConvertCharsetArray($additionalParams, LANG_CHARSET, "utf-8"); } $additionalParams['auth'] = $this->access_token; $http = new HttpClient(array('socketTimeout' => $this->httpTimeout)); $result = $http->post(CBitrixSeoOAuthInterface::URL . self::SERVICE_URL . $methodName, $additionalParams); /* AddMessage2Log(array( CBitrixSeoOAuthInterface::URL.self::SERVICE_URL.$methodName, $additionalParams, $http->getStatus(), $result, ));*/ $res = $this->prepareAnswer($result); if (!$res) { AddMessage2Log('Strange answer from Seo! ' . $http->getStatus() . ' ' . $result); } return $res; } else { throw new SystemException("No access token"); } }